@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Colors (unchanged) */
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #60a5fa;
  --primary-soft: #eff6ff;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  /* Shape */
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16,24,40,0.04), 0 1px 3px rgba(16,24,40,0.06);
  --shadow-md: 0 4px 12px rgba(16,24,40,0.06);
  --shadow-lg: 0 12px 28px rgba(16,24,40,0.10);
  --transition: all 0.15s ease;

  /* Spacing scale (use these instead of ad-hoc values) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;

  /* Layout */
  --sidebar-width: 248px;
  --sidebar-collapsed-width: 68px;
  --content-max: 1680px;
  --control-height: 40px;
  --control-height-sm: 34px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  line-height: 1.55;
  font-size: 14.5px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* ===== Sidebar ===== */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width 0.2s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 1.25rem;
  height: 68px;
  flex-shrink: 0;
}

.sidebar-brand .logo {
  width: 34px;
  height: 34px;
  min-width: 34px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1rem;
  box-shadow: 0 2px 6px rgba(59,130,246,0.35);
}

.brand-text {
  font-size: 1.125rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--gray-900);
  white-space: nowrap;
}

/* User card */
.sidebar-user-card {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 var(--space-3) var(--space-3);
  padding: var(--space-3);
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  flex-shrink: 0;
}

.user-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.user-card-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
  line-height: 1.3;
}

.user-card-info .user-name {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-900);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-card-logout { margin: 0; }

.user-card-logout .btn-logout-nav {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 0.9375rem;
}

.user-card-logout .btn-logout-nav:hover { background: #fee2e2; }

.sidebar-nav {
  flex: 1;
  padding: var(--space-2) var(--space-3) var(--space-4);
  overflow-y: auto;
  overflow-x: hidden;
}

.nav-section { margin-bottom: var(--space-3); }

.nav-section-label {
  padding: var(--space-3) var(--space-3) var(--space-2);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-400);
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: 40px;
  padding: 0 var(--space-3);
  margin-bottom: 2px;
  color: var(--gray-600);
  font-weight: 500;
  border-radius: var(--radius);
  transition: var(--transition);
  white-space: nowrap;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: inherit;
  font-family: inherit;
}

.nav-item:hover { color: var(--gray-900); background: var(--gray-100); }

.nav-item.active {
  color: var(--primary-dark);
  background: var(--primary-soft);
  font-weight: 600;
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--gray-400);
}

.nav-icon svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover .nav-icon { color: var(--gray-600); }
.nav-item.active .nav-icon { color: var(--primary); }

.nav-label { overflow: hidden; text-overflow: ellipsis; }

.nav-item-toggle { justify-content: flex-start; }
.nav-chevron { display: inline-flex; color: var(--gray-400); opacity: 0; transition: var(--transition); }
.nav-chevron svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.15s ease; }
.nav-chevron.is-open svg { transform: rotate(90deg); }
.nav-item-toggle:hover .nav-chevron,
.nav-item-toggle:focus-visible .nav-chevron { opacity: 1; }

/* Unterpunkte als Baum: senkrechte Linie unter dem Icon, je Eintrag ein Bogen */
.nav-subitems {
  margin: 0 0 var(--space-2) 1.375rem;
  padding-left: 0.875rem;
}

.nav-item-sub {
  height: 36px;
  padding: 0 var(--space-2);
  font-size: 0.875rem;
  overflow: visible;
}

.nav-item-sub::before,
.nav-item-sub::after {
  content: '';
  position: absolute;
  left: -0.875rem;
  border: 0 solid var(--gray-300);
  pointer-events: none;
}

.nav-item-sub::before {
  top: -2px;
  height: calc(50% + 2px);
  width: 0.625rem;
  border-left-width: 1px;
  border-bottom-width: 1px;
  border-bottom-left-radius: 8px;
}

.nav-item-sub:not(:last-child)::after {
  top: 0;
  bottom: -2px;
  border-left-width: 1px;
}

.nav-item-row { position: relative; }
.nav-item-row .nav-item-toggle { padding-right: 2.5rem; }
.nav-row-action {
  position: absolute;
  top: 50%;
  right: var(--space-2);
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius);
  color: var(--gray-400);
  transition: var(--transition);
}
.nav-row-action svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.nav-row-action:hover { color: var(--gray-700); background: var(--gray-200); }
.nav-row-action.active { color: var(--primary); background: var(--primary-soft); }

.sidebar-footer { padding: var(--space-2) 0; border-top: 1px solid var(--gray-200); }
.sidebar-user { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-2) var(--space-4); }
.user-name { font-size: 0.8125rem; font-weight: 500; color: var(--gray-700); white-space: nowrap; }

.btn-logout-nav {
  font-size: 0.75rem;
  color: var(--gray-500);
  border: none;
  background: none;
  cursor: pointer;
  transition: var(--transition);
  font-family: inherit;
}
.btn-logout-nav:hover { color: var(--danger); }

/* ===== Main layout ===== */
.main {
  margin-left: var(--sidebar-width);
  padding: var(--space-6) var(--space-7);
  min-height: 100vh;
  transition: margin-left 0.2s ease;
}

/* Every page's content is centered in the same column so edges line up */
.main > * {
  max-width: var(--content-max);
  margin-left: auto;
  margin-right: auto;
}

.main-no-sidebar {
  margin-left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}

/* Tabellen-Seiten (Pipeline) nutzen die volle Breite – auf großen Bildschirmen passen mehr Spalten */
.main:has(> .pipeline-layout) > * { max-width: none; }

/* Unauthenticated pages (login) are full-bleed */
.main.main--bare { margin-left: 0; padding: 0; }
.main--bare > * { max-width: none; }

/* ===== Page header (shared by all pages) ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  min-height: 56px;
  margin-bottom: var(--space-6);
}

.page-title {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  color: var(--gray-900);
}

.page-subtitle {
  margin-top: 2px;
  font-size: 0.875rem;
  color: var(--gray-500);
}

.page-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}
/* Viele Buttons (Pipeline als Admin): umbrechen statt die Seite breiter zu machen */
.page-header:has(.pd-dock) .page-actions {
  flex-wrap: wrap;
  justify-content: flex-end;
  flex-shrink: 1;
  min-width: 0;
}

.page-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-500);
}
.page-breadcrumb:hover { color: var(--gray-900); }

/* Vertical rhythm helpers */
.section { margin-bottom: var(--space-5); }

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-height);
  padding: 0 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(59,130,246,0.25); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 1px 2px rgba(37,99,235,0.3); }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.95); color: #fff; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.95); color: #fff; }

.btn-secondary {
  background: #fff;
  color: var(--gray-700);
  border-color: var(--gray-200);
  box-shadow: 0 1px 2px rgba(16,24,40,0.04);
}
.btn-secondary:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-900); }

.btn-sm { height: var(--control-height-sm); padding: 0 0.875rem; font-size: 0.8125rem; }

/* ===== Cards ===== */
.card {
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-200);
}

.card-header {
  min-height: 64px;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--gray-900);
}

.card-body { padding: var(--space-5); }

/* ===== Forms ===== */
.form-group { margin-bottom: 1.25rem; }

.form-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-700);
}

.form-input,
.form-select,
.form-textarea,
:where(.main) input:where([type=text], [type=email], [type=search], [type=password], [type=tel], [type=url], [type=number], [type=date], [type=time], [type=datetime-local]),
:where(.main) select,
:where(.main) textarea {
  width: 100%;
  height: var(--control-height);
  padding: 0 0.875rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  background: #fff;
  color: var(--gray-900);
  font-size: 0.875rem;
  font-family: inherit;
  transition: var(--transition);
}

.form-textarea,
:where(.main) textarea {
  height: auto;
  padding: 0.625rem 0.875rem;
  line-height: 1.5;
}

.form-input::placeholder, :where(.main) input::placeholder, :where(.main) textarea::placeholder { color: var(--gray-400); }

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
:where(.main) input:focus,
:where(.main) select:focus,
:where(.main) textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

/* ===== Filter / toolbar row ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  margin-bottom: var(--space-5);
}
.filter-bar form { display: flex; gap: var(--space-2); flex: 1; min-width: 260px; }
.filter-bar .form-select { width: auto; min-width: 180px; }

/* ===== Table ===== */
.card > .table-wrapper { border-radius: var(--radius-lg); }
.table-wrapper { overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; }

.table th {
  padding: 0.75rem 1.25rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--gray-500);
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.table th:first-child { border-top-left-radius: var(--radius-lg); }
.table th:last-child { border-top-right-radius: var(--radius-lg); }

.table td {
  padding: 0.875rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--gray-50); }
.table tbody tr.selected { background: var(--primary-soft); }

/* ===== Badges ===== */
.badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-primary { background: #dbeafe; color: #1d4ed8; }
.badge-success { background: #d1fae5; color: #047857; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-gray { background: var(--gray-100); color: var(--gray-600); }

/* ===== Grid ===== */
.grid {
  display: grid;
  gap: var(--space-5);
  align-items: stretch;
}
.grid > .card, .grid > .stat-card { height: 100%; }
/* Spalten dürfen schmaler werden als ihr Inhalt (sonst läuft die Seite auf dem Handy seitlich über) */
.grid > * { min-width: 0; }

.grid-cols-1 { grid-template-columns: 1fr; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1100px) {
  .grid-cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .grid-cols-2, .grid-cols-3, .grid-cols-4 { grid-template-columns: 1fr; }
}

/* ===== Stat cards ===== */
.stat-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 132px;
  padding: var(--space-5);
  border-radius: var(--radius-lg);
  background: #fff;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}

.stat-label { font-size: 0.8125rem; font-weight: 500; color: var(--gray-500); }

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--gray-900);
  line-height: 1.15;
}

.stat-change { font-size: 0.8125rem; min-height: 1.25rem; }
.stat-change.positive { color: var(--success); }
.stat-change.negative { color: var(--danger); }

/* ===== Loading ===== */
.loading {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--gray-500);
  font-size: 0.875rem;
}

.loading::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 2px solid var(--gray-300);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Toast notifications ===== */
.toast-stack {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 1300;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  max-width: min(440px, calc(100vw - 2rem));
}
.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  color: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  line-height: 1.45;
  animation: slideIn 0.3s ease;
  box-shadow: var(--shadow-lg);
  user-select: text;
}
.toast-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.toast-actions { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; margin: -0.125rem -0.375rem -0.125rem 0; }
.toast-actions button { border: 0; background: rgba(255, 255, 255, 0.18); color: #fff; font: inherit; font-size: 0.75rem; font-weight: 600; padding: 0.25rem 0.5rem; border-radius: var(--radius-sm); cursor: pointer; }
.toast-actions button:hover { background: rgba(255, 255, 255, 0.3); }
.toast-actions .toast-close { background: none; font-size: 1.125rem; line-height: 1; padding: 0.125rem 0.375rem; }
@media (max-width: 640px) { .toast-stack { right: var(--space-3); left: var(--space-3); bottom: calc(var(--space-3) + 90px); max-width: none; } .toast { width: 100%; } }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 4rem var(--space-6);
  color: var(--gray-400);
}
.empty-state-icon { font-size: 2.5rem; margin-bottom: var(--space-4); opacity: 0.7; }
.empty-state-title { font-size: 1.125rem; font-weight: 600; color: var(--gray-600); margin-bottom: var(--space-2); }
.empty-state-text { font-size: 0.875rem; max-width: 400px; margin: 0 auto var(--space-5); }

/* ===== Pipeline: stage tabs ===== */
.stage-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: var(--space-5);
  padding-bottom: 0;
}

.stage-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: var(--transition);
}

.stage-tab:hover {
  color: var(--gray-800);
}

.stage-tab.active {
  color: var(--gray-900);
  border-bottom-color: var(--primary);
}

.stage-tab .badge {
  font-size: 0.75rem;
}

/* ===== Pipeline: toolbar ===== */
.pipeline-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: var(--space-4);
}

.pipeline-toolbar .search-input-wrap {
  flex: 1;
  max-width: 360px;
  position: relative;
}

.pipeline-toolbar .search-input-wrap input {
  width: 100%;
  height: var(--control-height);
  padding: 0 0.875rem 0 2.25rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
}

.pipeline-toolbar .search-input-wrap::before {
  content: '🔍';
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.8125rem;
  opacity: 0.5;
}

.toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  height: var(--control-height);
  padding: 0 0.875rem;
  border: 1px solid var(--gray-300);
  background: #fff;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  font-family: inherit;
  position: relative;
}

.toolbar-btn:hover {
  background: var(--gray-50);
}

.toolbar-dropdown {
  position: absolute;
  top: calc(100% + 0.375rem);
  right: 0;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 200px;
  z-index: 50;
}

.toolbar-dropdown label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.625rem;
  font-size: 0.8125rem;
  color: var(--gray-700);
  cursor: pointer;
  border-radius: var(--radius-sm);
}

.toolbar-dropdown label:hover {
  background: var(--gray-50);
}

/* Handy: Filter-/Spalten-Menü als Leiste am unteren Rand, scrollbar statt aus dem Bild zu ragen */
@media (max-width: 640px) {
  .toolbar-dropdown {
    position: fixed;
    top: auto;
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
    max-height: 70vh;
    max-height: 70dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    z-index: 1050;
    border-radius: var(--radius-lg);
    box-shadow: 0 -8px 32px rgba(16, 24, 40, 0.22);
  }
  .toolbar-dropdown label { padding: 0.75rem 0.625rem; font-size: 0.9375rem; }
}

/* ===== Pipeline: split layout ===== */
.pipeline-layout {
  display: flex;
  align-items: flex-start;
  gap: 0;
  position: relative;
}

.pipeline-list-col {
  flex: 1;
  min-width: 0;
}

/* ===== Detail panel ===== */
.detail-panel {
  width: clamp(520px, 50vw, 760px);
  min-width: 520px;
  background: #fff;
  border-left: 1px solid var(--gray-200);
  border-radius: var(--radius-lg) 0 0 var(--radius-lg);
  box-shadow: var(--shadow-lg);
  align-self: stretch;
  display: flex;
  flex-direction: column;
  margin-left: 1.25rem;
  animation: panelIn 0.2s ease;
}

@keyframes panelIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

.detail-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--gray-100);
  gap: 0.75rem;
}

.detail-panel-header h2 {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--gray-900);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-panel-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.btn-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  background: #fff;
  color: var(--gray-600);
  cursor: pointer;
  font-size: 1rem;
}

.btn-icon:hover {
  background: var(--gray-50);
}

.btn-icon-close {
  border-color: transparent;
  color: var(--gray-400);
}

.btn-icon-close:hover {
  color: var(--danger);
  background: #fee2e2;
}

.detail-tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--gray-100);
}

.detail-tab {
  padding: 0.75rem 0.5rem;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-500);
  cursor: pointer;
  border-bottom: 2px solid transparent;
}

.detail-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.detail-section {
  border: 1px solid var(--gray-100);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.detail-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 1.125rem;
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--gray-900);
  background: var(--gray-50);
}

.detail-section-body {
  padding: 1.125rem;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--gray-500);
  margin-bottom: 0.375rem;
}

.contact-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.875rem;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  margin-bottom: 0.625rem;
}

.contact-card:last-child {
  margin-bottom: 0;
}

.contact-card-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--gray-900);
  margin-bottom: 0.125rem;
}

.contact-card-meta {
  font-size: 0.8125rem;
  color: var(--gray-500);
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.contact-card-actions {
  display: flex;
  gap: 0.375rem;
  flex-shrink: 0;
}

.notes-textarea {
  width: 100%;
  min-height: 160px;
  padding: 0.75rem;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-family: inherit;
  resize: vertical;
}

.activity-item {
  display: flex;
  gap: 0.875rem;
  margin-bottom: 1rem;
}

.activity-icon {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
}

/* ===== Responsive ===== */
/* Schmale Fenster: nur Icons. Auf dem Handy ist das Menü ausgeklappt geöffnet (body.nav-open) – dann gilt wieder die volle Leiste. */
@media (max-width: 1024px) {
  body:not(.nav-open) .sidebar {
    width: var(--sidebar-collapsed-width);
  }
  body:not(.nav-open) .nav-label,
  body:not(.nav-open) .nav-section-label,
  body:not(.nav-open) .brand-text,
  body:not(.nav-open) .sidebar-user {
    display: none;
  }
  body:not(.nav-open) .sidebar-user-card,
  body:not(.nav-open) .nav-subitems,
  body:not(.nav-open) .nav-chevron,
  body:not(.nav-open) .nav-row-action,
  body:not(.nav-open) .up-appts {
    display: none !important;
  }
  body:not(.nav-open) .nav-item {
    justify-content: center;
    padding: 0;
  }
  body:not(.nav-open) .nav-icon {
    margin: 0;
  }
  .main {
    margin-left: var(--sidebar-collapsed-width);
    padding: var(--space-5);
  }
}

/* Handy: Leiste oben mit Menü-Knopf, die Seitenleiste fährt bei Bedarf herein */
.mobile-topbar,
.mobile-nav-backdrop { display: none; }

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }
  body.nav-open .sidebar {
    transform: none;
    box-shadow: var(--shadow-lg);
  }
  .sidebar-nav { overflow-y: auto; }
  .mobile-topbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    position: sticky;
    top: 0;
    z-index: 150;
    height: 52px;
    padding: 0 var(--space-3);
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
  }
  .mobile-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: var(--radius-sm);
    background: none;
    color: var(--gray-700);
    cursor: pointer;
  }
  .mobile-nav-btn:active { background: var(--gray-100); }
  body.nav-open .mobile-nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 190;
    background: rgba(17, 24, 39, 0.35);
  }
  .main {
    margin-left: 0;
    padding: var(--space-4);
  }
  .page-header {
    flex-wrap: wrap;
  }
  .pipeline-toolbar {
    flex-wrap: wrap;
  }
  .page-actions {
    flex-wrap: wrap;
    flex-shrink: 1;
    min-width: 0;
  }
  /* Power-Dialer-Start bleibt unten am Bildschirm, egal wie weit man in der Liste gescrollt hat
     (das Lead-Panel liegt darüber, solange ein Lead offen ist) */
  .page-actions .pd-dock {
    position: fixed;
    left: var(--space-3);
    right: var(--space-3);
    bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
    z-index: 800;
    align-items: stretch;
    padding: 0.5rem;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 28px rgba(16, 24, 40, 0.18);
  }
  /* liegt auch über dem geöffneten Lead-Panel – so lässt sich „ab diesem Lead“ starten; während der Dialer läuft,
     übernimmt die Karte im Panel */
  .page-actions .pd-dock { z-index: 950; }
  .page-actions .pd-dock.pd-dock-busy { display: none !important; }
  .detail-panel .detail-panel-body { padding-bottom: 7rem; }
  body.nav-open .sidebar { z-index: 1000; }
  body.nav-open .mobile-nav-backdrop { z-index: 990; }
  .page-actions .pd-dock .pd-split { display: flex; }
  .page-actions .pd-dock #pd-start-btn { flex: 1; justify-content: center; }
  .page-actions .pd-dock .pd-next-hint { max-width: none; text-align: center; padding: 0 0.25rem 0.125rem; }
  .page-actions .pd-dock .pd-goal { max-width: none; padding: 0 0.25rem 0.125rem; }
  #pd-card-goal .pd-goal { display: block; }
  .pipeline-layout { padding-bottom: 7rem; }
  /* Notbremse: nichts darf die Seite breiter als den Bildschirm machen – sonst vergrößert Android die
     Seite und Dialoge landen außerhalb des sichtbaren Bereichs */
  html {
    overflow-x: hidden;
  }
  .modal-overlay {
    padding: var(--space-3);
  }
}

@media (max-width: 1100px) {
  .pipeline-layout {
    flex-direction: column;
    align-items: stretch;
  }
  .detail-panel {
    width: 100%;
    min-width: 0;
    max-width: none;
    margin-left: 0;
    margin-top: 1.25rem;
    border-radius: var(--radius-lg);
    border-left: 1px solid var(--gray-200);
  }
  .field-grid {
    grid-template-columns: 1fr;
  }
}
/* Cards stacked directly in the page flow get uniform spacing */
.main > .card { margin-bottom: var(--space-5); }
.main > .card:last-child { margin-bottom: 0; }

/* Stat cards nested inside another card are flat tiles */
.card .stat-card {
  min-height: 96px;
  padding: var(--space-4);
  background: var(--gray-50);
  border-color: var(--gray-100);
  box-shadow: none;
}

input[type=file].form-input {
  height: auto;
  padding: 0.5rem 0.75rem;
}

/* ===== Modal (Anruf loggen u.a.) ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: rgba(17, 24, 39, 0.45);
}

.modal {
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #fff;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-5) var(--space-3);
}

.modal-title { font-size: 1.125rem; font-weight: 700; letter-spacing: -0.01em; color: var(--gray-900); }
.modal-subtitle { margin-top: 2px; font-size: 0.8125rem; color: var(--gray-500); }
.modal-body { padding: var(--space-3) var(--space-5) var(--space-5); }

.calllog-question { margin-bottom: var(--space-4); font-weight: 600; color: var(--gray-900); }
.calllog-choices { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--space-3); }
.calllog-choices .btn { white-space: normal; min-width: 0; line-height: 1.25; }
.calllog-feedback .calllog-when { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.calllog-feedback .calllog-when > * { min-width: 0; }
.calllog-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.calllog-actions { display: flex; justify-content: flex-end; gap: var(--space-3); margin-top: var(--space-5); }
.calllog-error {
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius);
  background: #fee2e2;
  color: #b91c1c;
  font-size: 0.8125rem;
}

.chip {
  height: 28px;
  padding: 0 0.75rem;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  background: #fff;
  color: var(--gray-600);
  font-family: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}
.chip:hover { background: var(--primary-soft); border-color: var(--primary-light); color: var(--primary-dark); }

.row-actions { display: inline-flex; align-items: center; gap: var(--space-2); }

/* ===== Dashboard ===== */
.stat-change .muted { color: var(--gray-500); }
.stat-change .positive { color: var(--success); font-weight: 600; }
.stat-change .negative { color: var(--danger); font-weight: 600; }

.empty-state.compact { padding: var(--space-6) var(--space-5); }

/* Listen in Karten (Wiedervorlagen, Aktivitäten) */
.list { display: flex; flex-direction: column; }
.list-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0.875rem var(--space-5);
  border-bottom: 1px solid var(--gray-100);
  color: inherit;
  transition: var(--transition);
}
.list-row:last-child { border-bottom: none; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.list-row:hover { background: var(--gray-50); color: inherit; }
.list-main { min-width: 0; flex: 1; }
.list-title { font-weight: 600; font-size: 0.875rem; color: var(--gray-900); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 0.8125rem; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-meta { font-size: 0.8125rem; color: var(--gray-400); white-space: nowrap; }

/* Balkendiagramm: Anrufe pro Tag */
.bars { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: var(--space-3); height: 220px; align-items: stretch; }
.bar-col { display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar-value { font-size: 0.8125rem; font-weight: 600; color: var(--gray-700); }
.bar-track { flex: 1; width: 100%; max-width: 44px; display: flex; align-items: flex-end; background: var(--gray-50); border-radius: var(--radius-sm); overflow: hidden; }
.bar { width: 100%; min-height: 2px; background: var(--primary-light); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.bar-today { background: var(--primary); }
.bar-label { font-size: 0.75rem; color: var(--gray-500); }
.bar-label-today { color: var(--gray-900); font-weight: 600; }

/* Pipeline-Überblick */
.funnel { display: flex; flex-direction: column; gap: var(--space-3); }
.funnel-row { display: grid; grid-template-columns: minmax(110px, 30%) 1fr 48px; align-items: center; gap: var(--space-3); }
.funnel-name { font-size: 0.8125rem; color: var(--gray-700); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.funnel-track { height: 10px; background: var(--gray-100); border-radius: 999px; overflow: hidden; }
.funnel-bar { height: 100%; min-width: 4px; border-radius: 999px; }
.funnel-count { text-align: right; font-size: 0.8125rem; font-weight: 600; color: var(--gray-900); }

/* ===== Phasen-Verwaltung ===== */
.stage-list { display: flex; flex-direction: column; gap: var(--space-2); }
.stage-row {
  display: flex; align-items: center; gap: var(--space-2);
  padding: 0.375rem 0.5rem 0.375rem var(--space-3);
  background: var(--gray-50); border: 1px solid var(--gray-200); border-radius: var(--radius);
}
.stage-row.is-dragging { opacity: 0.4; }
.stage-row__grip { color: var(--gray-400); cursor: grab; letter-spacing: -2px; }
.stage-row__name { flex: 1; font-weight: 500; color: var(--gray-900); }
.stage-row__count { font-size: 0.75rem; color: var(--gray-500); margin-right: var(--space-2); }
.stage-row__delete { color: #b91c1c; }
.btn-ghost[disabled] { opacity: 0.3; cursor: default; }
.btn-ghost { background: transparent; color: var(--gray-600); border: 1px solid transparent; }
.btn-ghost:hover { background: var(--gray-100); color: var(--gray-900); }

/* ===== Einstellungen / Pipelines (einheitliche Bausteine) ===== */
.grid-start { align-items: start; }
.grid-start > .card { height: auto; }
.stack { display: flex; flex-direction: column; gap: var(--space-5); }

.profile-head { display: flex; align-items: center; gap: var(--space-4); margin-bottom: var(--space-5); }
.avatar-lg {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary-dark);
  font-weight: 700; font-size: 1rem; flex-shrink: 0;
}
.profile-name { font-weight: 600; color: var(--gray-900); }
.profile-mail { font-size: 0.8125rem; color: var(--gray-500); }

.item-row {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--gray-200); border-radius: var(--radius); background: #fff;
}
.item-row + .item-row { margin-top: var(--space-3); }
.item-title { font-weight: 600; font-size: 0.875rem; color: var(--gray-900); }
.item-sub { font-size: 0.8125rem; color: var(--gray-500); word-break: break-all; }
.item-actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

.pipeline-card { display: block; text-decoration: none; color: inherit; height: 100%; }
.pipeline-card .card { height: 100%; transition: var(--transition); }
.pipeline-card:hover .card { box-shadow: var(--shadow-md); border-color: var(--gray-300); }
.pipeline-card .card-body { display: flex; flex-direction: column; gap: var(--space-4); height: 100%; }
.pipeline-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); }
.pipeline-name { font-weight: 600; font-size: 1.0625rem; color: var(--gray-900); }
.pipeline-desc { font-size: 0.8125rem; color: var(--gray-500); margin-top: 2px; }
.pipeline-stats { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--gray-100); border-bottom: 1px solid var(--gray-100); padding: var(--space-3) 0; text-align: center; }
.pipeline-stats strong { display: block; font-size: 1.25rem; color: var(--gray-900); }
.pipeline-stats span { font-size: 0.75rem; color: var(--gray-500); }
.stagebar { display: flex; gap: 4px; }
.stagebar i { flex: 1; height: 4px; border-radius: 2px; background: var(--gray-300); }
.pipeline-foot { margin-top: auto; display: flex; gap: var(--space-2); }
.pipeline-foot .btn-manage { flex: 1; }

.stage-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.stage-row input.form-input { height: var(--control-height-sm); }
.stage-row.is-dragging { opacity: 0.4; }
.stage-row .stage-name-input { flex: 1; background: transparent; border-color: transparent; }
.stage-row .stage-name-input:hover { border-color: var(--gray-200); background: #fff; }
.modal.modal-wide { max-width: 560px; }
.subform { margin-top: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--gray-100); }
.color-row { display: flex; gap: var(--space-2); align-items: center; }
.color-row input[type=color] { width: 40px; height: var(--control-height); padding: 2px; border: 1px solid var(--gray-200); border-radius: var(--radius); background: #fff; cursor: pointer; }
.empty-state .btn { margin-top: var(--space-2); }
.btn-outline { background: #fff; color: var(--gray-700); border-color: var(--gray-200); box-shadow: 0 1px 2px rgba(16,24,40,0.04); }
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-300); color: var(--gray-900); }

/* ===== Lead-Detailpanel (kompakt, Wichtiges oben) ===== */
.detail-panel-header { padding: 1rem 1.25rem; }
.dp-title { min-width: 0; }
.dp-sub { font-size: 0.8125rem; color: var(--gray-500); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-panel-body { display: flex; flex-direction: column; gap: 1.125rem; }
.detail-panel .btn-icon { font-size: 1.125rem; line-height: 1; }
.detail-panel .btn-icon:disabled { opacity: .35; cursor: default; }
.btn-icon-sm { width: 28px; height: 28px; border-radius: var(--radius-sm); font-size: 0.875rem; }
.btn-icon-danger { color: var(--gray-500); }
.btn-icon-danger:hover { color: var(--danger); background: #fee2e2; border-color: #fecaca; }
.dp-hero { background: var(--primary-soft); border: 1px solid #dbeafe; border-radius: var(--radius-lg); padding: 0.875rem 1rem; }
.dp-hero-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.dp-phone { font-size: 1.1875rem; font-weight: 700; letter-spacing: -0.01em; color: var(--gray-900); text-decoration: none; }
a.dp-phone:hover { color: var(--primary-dark); }
.dp-phone-empty { font-size: 0.9375rem; font-weight: 500; color: var(--gray-400); }
.dp-quick { margin-top: 0.5rem; font-size: 0.8125rem; color: var(--gray-500); display: flex; flex-wrap: wrap; gap: 0.25rem 0; }
.dp-link { color: var(--primary-dark); text-decoration: none; }
.dp-link:hover { text-decoration: underline; }
.dp-status { gap: 0.75rem; }
.dp-static { font-size: 0.875rem; color: var(--gray-700); min-height: var(--control-height); display: flex; align-items: center; }
.dp-block-head { display: flex; align-items: center; justify-content: space-between; min-height: 30px; margin-bottom: 0.375rem; font-size: 0.8125rem; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.04em; }
.ap-row { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.5rem 0.75rem; border: 1px solid var(--gray-200); border-radius: var(--radius); margin-bottom: 0.375rem; }
.ap-name { font-size: 0.875rem; font-weight: 600; color: var(--gray-900); }
.ap-role { font-size: 0.75rem; font-weight: 400; color: var(--gray-500); }
.ap-meta { font-size: 0.8125rem; color: var(--gray-500); margin-top: 1px; }
.ap-actions { display: flex; gap: 0.25rem; flex-shrink: 0; }
.dp-empty { font-size: 0.8125rem; color: var(--gray-400); padding: 0.25rem 0; }
.dp-right { text-align: right; margin-top: 0.5rem; }
.call-row { padding: 0.625rem 0.75rem; border: 1px solid var(--gray-200); border-radius: var(--radius); margin-bottom: 0.375rem; }
.dp-meta { display: flex; flex-wrap: wrap; gap: 0.25rem 1rem; font-size: 0.75rem; color: var(--gray-500); padding-top: 0.875rem; border-top: 1px solid var(--gray-100); }
.dp-meta b { color: var(--gray-400); font-weight: 600; margin-right: 0.25rem; }
.dp-meta-action { flex-basis: 100%; margin-top: 0.375rem; }

.dp-quick { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.625rem; }
.dp-chip { display: inline-flex; align-items: center; gap: 0.375rem; max-width: 100%; min-width: 0; height: 28px; padding: 0 0.625rem; background: #fff; border: 1px solid #dbeafe; border-radius: 999px; font-size: 0.8125rem; font-weight: 500; color: var(--primary-dark); text-decoration: none; }
.dp-chip:hover { background: #fff; border-color: var(--primary-light); }
.dp-chip svg { flex-shrink: 0; }
.dp-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.fu-chips { display: flex; flex-wrap: wrap; gap: 0.375rem; margin-top: 0.5rem; }

.stage-row .stage-cat { width: auto; max-width: 168px; height: var(--control-height-sm); padding-top: 0; padding-bottom: 0; font-size: 0.8125rem; flex-shrink: 0; }

/* Detail-Panel: Tabs + Header-Aktionen */
.dp-call-btn { display: inline-flex; align-items: center; gap: 0.375rem; }
.detail-panel-actions .btn-outline { display: inline-flex; align-items: center; gap: 0.375rem; }
.dp-tabs { display: flex; gap: 0.25rem; padding: 0.25rem; background: var(--gray-50); border-radius: var(--radius-lg); }
.dp-tab { flex: 1; padding: 0.5rem 0.75rem; border: none; background: transparent; border-radius: var(--radius); font-family: inherit; font-size: 0.875rem; font-weight: 600; color: var(--gray-600); cursor: pointer; }
.dp-tab:hover { color: var(--gray-900); }
.dp-tab.active { background: #fff; color: var(--primary-dark); box-shadow: 0 1px 2px rgba(16,24,40,0.08); }
.dp-tab-count { font-weight: 500; color: var(--gray-500); }
.dp-tab-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); vertical-align: middle; margin-left: 2px; }
.dp-pane { display: flex; flex-direction: column; gap: 1.125rem; }
.detail-panel .notes-textarea { min-height: 220px; }

/* Anruf loggen (Modal + eingebettet) */
.calllog-path-head { display: flex; align-items: center; justify-content: space-between; }
.calllog-context { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.25rem 0.75rem; margin-bottom: 0.875rem; padding: 0.5rem 0.75rem; border-radius: var(--radius); background: var(--primary-soft); font-size: 0.8125rem; color: var(--gray-700); }
.calllog-reset { border: none; background: none; padding: 0; font: inherit; font-size: 0.8125rem; color: var(--primary-dark); cursor: pointer; }
.calllog-reset:hover { text-decoration: underline; }
.calllog-path { padding: 0.625rem 0.75rem; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--gray-50); font-size: 0.875rem; font-weight: 600; color: var(--success, #16a34a); min-height: var(--control-height); display: flex; align-items: center; }
.calllog-when { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.calllog-money { display: flex; align-items: center; gap: 0.5rem; }
.calllog-money .form-input { flex: 1; min-width: 0; }
.calllog-money span { font-size: 0.8125rem; color: var(--gray-500); white-space: nowrap; }
.calllog-missing { margin-top: var(--space-2); font-size: 0.8125rem; color: var(--gray-500); text-align: right; }
.calllog-actions .btn-primary:disabled { opacity: 0.45; cursor: not-allowed; }
.dp-calllog { border: 1px solid #dbeafe; background: var(--primary-soft); border-radius: var(--radius-lg); padding: 1rem; margin-bottom: 1.125rem; }
.dp-calllog:empty { display: none; }
.dp-calllog .calllog-path, .dp-calllog .gray-bg { background: #fff; }
.dp-calllog-title { font-size: 0.8125rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--gray-700); margin-bottom: 0.75rem; }

/* Detail-Panel als Overlay über der Liste (wächst mit dem Inhalt, kein leerer Bereich) */
.detail-panel {
  position: fixed;
  /* --dp-top: unter dem Power-Dialer-Knopf, damit „ab diesem Lead starten“ erreichbar bleibt (setzt placeDetailPanel()) */
  top: var(--dp-top, 1rem);
  right: 1rem;
  bottom: auto;
  z-index: 900;
  width: clamp(560px, 55vw, 820px);
  min-width: 0;
  max-height: calc(100vh - var(--dp-top, 1rem) - 1rem);
  margin: 0;
  align-self: auto;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(16, 24, 40, 0.18);
}
.detail-panel .detail-panel-body { flex: 0 1 auto; min-height: 0; }
@media (max-width: 1100px) {
  .detail-panel { top: var(--dp-top, 0px); right: 0; width: 100%; max-height: calc(100vh - var(--dp-top, 0px)); border-radius: 0; }
}
/* Handy: Panel über den ganzen Bildschirm, Kopfzeile zweizeilig (Name oben, Knöpfe darunter, Schließen oben rechts) */
@media (max-width: 768px) {
  .detail-panel { top: 0; bottom: 0; height: 100vh; height: 100dvh; max-height: none; border: 0; box-shadow: none; animation: none; }
  .detail-panel .detail-panel-body { flex: 1 1 auto; padding: 1rem; }
  .detail-panel-header { position: relative; flex-wrap: wrap; padding: 0.75rem 1rem; row-gap: 0.625rem; }
  .detail-panel-header .dp-title { flex: 1 1 100%; padding-right: 2.75rem; }
  .detail-panel-actions { flex: 1 1 100%; flex-wrap: wrap; }
  .detail-panel-actions .btn-icon-close { position: absolute; top: 0.75rem; right: 1rem; }
}

/* ===== E-Mail verfassen ===== */
.ec-modal { max-width: 760px; }
@media (max-width: 640px) {
  /* Titel + Schließen in der ersten Zeile, „Von“ darunter über die volle Breite */
  .ec-header { flex-wrap: wrap; position: relative; padding-right: 3.25rem; }
  .ec-header #ec-close { position: absolute; top: var(--space-4); right: var(--space-4); }
  .ec-from { flex: 1 1 100%; min-width: 0; }
  .ec-from .form-select { min-width: 0; flex: 1; }
  .ec-menu-list { max-width: calc(100vw - 3rem); }
}
.ec-header { align-items: center; }
.ec-header .modal-title { margin-right: auto; }
.ec-from { display: flex; align-items: center; gap: 0.5rem; }
.ec-from-label { font-size: 0.75rem; color: var(--gray-500); }
.ec-from .form-select { min-width: 220px; height: var(--control-height-sm); }
.ec-field { margin-bottom: 1rem; }
.ec-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; min-height: var(--control-height); padding: 0.25rem 0.5rem; border: 1px solid var(--gray-200); border-radius: var(--radius); background: #fff; cursor: text; }
.ec-chips:focus-within { border-color: var(--primary-light); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }
.ec-chip { display: inline-flex; align-items: center; gap: 0.375rem; height: 26px; padding: 0 0.5rem 0 0.75rem; border-radius: 999px; background: var(--primary-soft); color: var(--primary-dark); font-size: 0.8125rem; }
.ec-chip button { border: none; background: none; color: inherit; cursor: pointer; font-size: 1rem; line-height: 1; padding: 0; }
.ec-chip-input { flex: 1; min-width: 140px; border: none !important; outline: none; box-shadow: none !important; background: transparent; padding: 0.25rem 0; font: inherit; font-size: 0.875rem; }
.ec-chip-input.ec-invalid { color: var(--danger); }
.ec-cc-toggles { margin-left: auto; display: flex; gap: 0.75rem; }
.ec-cc-toggles button { border: none; background: none; font: inherit; font-size: 0.8125rem; font-weight: 700; color: var(--gray-800); cursor: pointer; }
.ec-editor-wrap { border: 1px solid var(--gray-200); border-radius: var(--radius); overflow: visible; }
.ec-toolbar { display: flex; align-items: center; gap: 0.25rem; padding: 0.375rem 0.5rem; border-bottom: 1px solid var(--gray-100); flex-wrap: wrap; }
.ec-toolbar > button { min-width: 30px; height: 30px; border: none; background: none; border-radius: var(--radius-sm); color: var(--gray-600); font: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
.ec-toolbar > button:hover, .ec-menu-btn:hover { background: var(--gray-100); }
.ec-sep { width: 1px; height: 18px; background: var(--gray-200); margin: 0 0.25rem; }
.ec-menu { position: relative; }
.ec-menu-btn { height: 30px; padding: 0 0.625rem; border: none; background: var(--gray-50); border-radius: var(--radius-sm); font: inherit; font-size: 0.8125rem; font-weight: 600; color: var(--gray-800); cursor: pointer; }
.ec-menu-list { display: none; position: absolute; top: 34px; left: 0; z-index: 5; min-width: 200px; max-height: 240px; overflow-y: auto; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow-md); padding: 0.25rem; }
.ec-menu-list.open { display: block; }
.ec-menu-list button { display: block; width: 100%; text-align: left; border: none; background: none; padding: 0.4375rem 0.625rem; border-radius: var(--radius-sm); font: inherit; font-size: 0.8125rem; cursor: pointer; }
.ec-menu-list button:hover { background: var(--gray-100); }
.ec-menu-empty { padding: 0.5rem 0.625rem; font-size: 0.8125rem; color: var(--gray-400); }
.ec-editor { min-height: 220px; max-height: 42vh; overflow-y: auto; padding: 0.875rem 1rem; font-size: 0.9375rem; line-height: 1.55; outline: none; }
.ec-editor h1 { font-size: 1.25rem; margin: 0.5rem 0; }
.ec-editor h2 { font-size: 1.0625rem; margin: 0.5rem 0; }
.ec-editor ul, .ec-editor ol { padding-left: 1.25rem; margin: 0.25rem 0; }
.ec-editor p { margin: 0 0 0.5rem; }
.ec-signature { margin-top: 1rem; padding-top: 0.75rem; border-top: 1px solid var(--gray-200); }
.ec-empty { text-align: center; padding: 1.5rem 1rem; color: var(--gray-600); }
.ec-hint { font-size: 0.8125rem; color: var(--gray-500); margin: 0.25rem 0 1rem; }

/* ===== Arbeitslisten (automatische Zuteilung) ===== */
.wl-bar { margin-left: auto; display: flex; align-items: center; gap: 0.625rem; }
.wl-avatars { display: inline-flex; align-items: center; }
.wl-avatars .rep-dot { margin-right: 0; margin-left: -6px; box-shadow: 0 0 0 2px #fff; cursor: default; }
.wl-avatars .rep-wrap { position: relative; display: inline-flex; margin-left: -6px; }
.wl-avatars .rep-wrap:first-child { margin-left: 0; }
.wl-avatars .rep-wrap > .rep-dot { margin-left: 0; }
.wl-avatars .rep-wrap:hover { z-index: 30; }
/* Hover-Karte am Mitarbeiter-Avatar: Status, laufender Anruf, Leads */
.rep-pop { display: none; position: absolute; top: calc(100% + 8px); left: -6px; z-index: 30; min-width: 220px; max-width: 300px; padding: 0.625rem 0.75rem; background: #fff; border: 1px solid var(--gray-100); border-radius: var(--radius-lg); box-shadow: 0 8px 24px rgba(16,24,40,0.12); font-size: 0.75rem; color: var(--gray-600); text-align: left; white-space: normal; flex-direction: column; gap: 0.375rem; cursor: default; }
.rep-wrap:hover .rep-pop { display: flex; }
.rep-pop::before { content: ''; position: absolute; top: -9px; left: 0; right: 0; height: 9px; } /* Hover-Brücke zwischen Avatar und Karte */
.rep-pop-head { display: flex; align-items: center; gap: 0.5rem; }
.rep-pop .rep-dot { margin-left: 0; flex-shrink: 0; }
.rep-pop-name { display: block; font-size: 0.875rem; color: var(--gray-900); line-height: 1.2; }
.rep-pop-state { display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.625rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--gray-400); }
.rep-pop-state::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.rep-pop-state.online { color: #16a34a; }
.rep-pop-state.calling { color: #dc2626; }
.rep-pop-line b { color: var(--gray-900); font-weight: 600; }
.rep-pop-line.muted { color: var(--gray-400); }
.rep-pop-time { font-variant-numeric: tabular-nums; white-space: nowrap; }
.wl-pool { padding: 0.1875rem 0.625rem; border-radius: 999px; background: var(--gray-100); color: var(--gray-700); font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.wl-pool.low { background: #fef3c7; color: #92400e; }
.wl-warn { padding: 0.1875rem 0.625rem; border: none; border-radius: 999px; background: #fef3c7; color: #92400e; font: inherit; font-size: 0.75rem; font-weight: 600; cursor: pointer; }
button.wl-warn:hover { text-decoration: underline; }
.rep-dot { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; margin-right: 0.625rem; border-radius: 50%; color: #fff; font-size: 0.5625rem; font-weight: 700; letter-spacing: 0.02em; vertical-align: middle; flex-shrink: 0; }
.rep-dot-lg { width: 28px; height: 28px; font-size: 0.625rem; }
.rep-dot-empty { background: transparent; }
.rep-dot.is-offline { filter: grayscale(1); opacity: 0.45; }
.rep-dot.is-online { position: relative; }
.rep-dot.is-online::after { content: ''; position: absolute; right: -1px; bottom: -1px; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px #fff; }
.rep-dot.is-calling { animation: repCalling 1.6s ease-out infinite; }
@keyframes repCalling { 0% { box-shadow: 0 0 0 2px #fff, 0 0 0 2px rgba(34,197,94,0.7); } 100% { box-shadow: 0 0 0 2px #fff, 0 0 0 9px rgba(34,197,94,0); } }
/* Tagesziel-Ring ums Avatar (Admin-Übersicht) */
.rep-ring { display: inline-flex; padding: 2px; border-radius: 50%; background: conic-gradient(var(--ring) calc(var(--p) * 1%), var(--gray-200) 0); }
.wl-avatars .rep-ring .rep-dot { margin-left: 0; }
.wl-avatars .rep-wrap > .rep-ring { margin-left: 0; }
.deal-cell { display: flex; align-items: center; }

/* ===== Power-Dialer ===== */
.pd-dock { display: flex; flex-direction: column; align-items: flex-start; gap: 0.25rem; }
.pd-next-hint { max-width: 320px; font-size: 0.75rem; color: var(--gray-500); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-next-hint b { color: var(--gray-700); font-weight: 600; }
.pd-split { display: inline-flex; }
/* Tagesziel unter dem Startknopf (auf dem Handy in der Dialer-Karte) */
.pd-goal { width: 100%; min-width: 220px; max-width: 320px; }
.pd-goal-top { display: flex; align-items: baseline; gap: 0.375rem; font-size: 0.75rem; color: var(--gray-500); }
.pd-goal-top b { color: var(--gray-900); font-weight: 700; font-variant-numeric: tabular-nums; }
.pd-goal-rest { margin-right: auto; }
.pd-goal.is-done .pd-goal-rest { color: #16a34a; font-weight: 600; }
.pd-goal-streak { font-weight: 700; color: #ea580c; font-variant-numeric: tabular-nums; }
.pd-goal-streak.is-open { opacity: 0.55; }
.pd-goal-track { height: 6px; margin-top: 0.25rem; border-radius: 999px; background: var(--gray-200); overflow: hidden; }
.pd-goal-track span { display: block; height: 100%; border-radius: inherit; background: var(--primary, #3b82f6); transition: width 0.4s ease; }
.pd-goal.is-done .pd-goal-track span { background: #22c55e; }
#pd-card-goal .pd-goal { display: none; max-width: none; margin-bottom: 0.625rem; }
.pd-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 2000; }
/* Setter-Infos (Lead-Panel, Lead-Seite, Closing-Call) */
.si-head { display: flex; justify-content: space-between; gap: 0.5rem; margin-bottom: 0.5rem; font-size: 0.75rem; color: var(--gray-500); }
.si-count { font-weight: 600; color: var(--gray-700); white-space: nowrap; }
.si-status { text-align: right; }
.si-status.ok { color: #16a34a; }
.si-status.err { color: var(--danger, #dc2626); }
.si-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 0.625rem 0.75rem; }
.si-field { min-width: 0; }
.si-field .form-input, .si-field .form-select, .si-field .form-textarea { width: 100%; }
.si-wide { grid-column: 1 / -1; }
.si-help { margin-top: 0.2rem; font-size: 0.6875rem; color: var(--gray-400); }
.calllog-setter { margin-bottom: 0.875rem; }
.si-summary { padding: 0.625rem 0.75rem; border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--gray-50); }
.si-summary-title { margin-bottom: 0.375rem; font-size: 0.75rem; font-weight: 700; color: var(--gray-700); text-transform: uppercase; letter-spacing: 0.04em; }
.si-summary dl { display: grid; grid-template-columns: minmax(90px, max-content) 1fr; gap: 0.25rem 0.75rem; margin: 0; font-size: 0.8125rem; }
.si-summary dt { color: var(--gray-500); }
.si-summary dd { margin: 0; color: var(--gray-900); white-space: pre-wrap; overflow-wrap: anywhere; }
/* Einstellungen › Setter-Infos */
.sf-list { display: flex; flex-direction: column; }
.sf-row { display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0; border-bottom: 1px solid var(--gray-100); }
.sf-row:last-child { border-bottom: 0; }
.sf-move { display: inline-flex; flex-shrink: 0; }
.sf-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sf-meta { font-size: 0.75rem; color: var(--gray-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sf-del { font-size: 1.125rem; line-height: 1; }
/* Einstellungen: Übersicht mit großen Kacheln (Icon im farbigen Kreis, Titel, Beschreibung, Pfeil) */
.set-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1.25rem; margin-bottom: var(--space-5); }
@media (max-width: 1100px) { .set-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .set-tiles { grid-template-columns: 1fr; gap: 0.75rem; } }
.set-tile { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 0.375rem; padding: 1.5rem; background: #fff;
  border: 1px solid var(--gray-200); border-radius: var(--radius-lg, 12px); color: inherit; text-decoration: none;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04); transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.set-tile:hover { border-color: var(--gray-300); box-shadow: 0 8px 24px rgba(16, 24, 40, 0.08); transform: translateY(-1px); }
.set-tile:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.set-icon { display: inline-flex; align-items: center; justify-content: center; width: 52px; height: 52px; margin-bottom: 0.75rem; border-radius: 50%; background: var(--set-bg); color: var(--set-fg); }
.set-icon svg { width: 24px; height: 24px; }
.set-tile b { font-size: 1.0625rem; color: var(--gray-900); }
.set-desc { font-size: 0.875rem; line-height: 1.5; color: var(--gray-500); }
.set-arrow { position: absolute; top: 1.25rem; right: 1.25rem; color: var(--set-fg); opacity: 0.45; transition: opacity 0.15s, transform 0.15s; }
.set-tile:hover .set-arrow { opacity: 1; transform: translate(2px, -2px); }
@media (max-width: 640px) {
  .set-tile { flex-direction: row; flex-wrap: wrap; align-items: center; column-gap: 0.875rem; padding: 1rem; }
  .set-icon { width: 42px; height: 42px; margin: 0; }
  .set-tile b { flex: 1; }
  .set-desc { flex-basis: 100%; }
  .set-arrow { display: none; }
}
.set-c-blue { --set-bg: #eff6ff; --set-fg: #2563eb; }
.set-c-violet { --set-bg: #f5f3ff; --set-fg: #7c3aed; }
.set-c-sky { --set-bg: #f0f9ff; --set-fg: #0284c7; }
.set-c-gray { --set-bg: #f3f4f6; --set-fg: #4b5563; }
.set-c-green { --set-bg: #ecfdf5; --set-fg: #059669; }
.set-c-amber { --set-bg: #fffbeb; --set-fg: #d97706; }
.set-c-orange { --set-bg: #fff7ed; --set-fg: #ea580c; }
.set-c-pink { --set-bg: #fdf2f8; --set-fg: #db2777; }
.set-c-emerald { --set-bg: #f0fdf4; --set-fg: #16a34a; }
.set-c-indigo { --set-bg: #eef2ff; --set-fg: #4f46e5; }
.set-back { display: inline-block; margin-bottom: 0.25rem; font-size: 0.8125rem; font-weight: 600; color: var(--primary); text-decoration: none; }
.set-back[hidden] { display: none; }
.set-section { display: flex; flex-direction: column; gap: var(--space-5); }
.set-section[hidden] { display: none; }
/* Einstellungen › Tagesziele */
.goal-table .goal-input { max-width: 90px; }
.goal-days { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }
.goal-days label { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.8125rem; color: var(--gray-700); }
.goal-today { white-space: nowrap; font-variant-numeric: tabular-nums; }
/* Lead-Panel: „Anrufen“ + Dreieck für „Anruf loggen“ */
.dp-split { position: relative; display: inline-flex; }
.dp-split .dp-call-btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }
.dp-split .dp-caret { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(255,255,255,0.35); padding-left: 0.5rem; padding-right: 0.5rem; display: inline-flex; align-items: center; }
.dp-call-menu { position: absolute; top: calc(100% + 4px); left: 0; z-index: 60; min-width: 210px; padding: 0.25rem; background: #fff; border: 1px solid var(--gray-200); border-radius: var(--radius); box-shadow: var(--shadow-md); }
.dp-call-menu[hidden] { display: none; }
.dp-call-menu button { display: block; width: 100%; padding: 0.5rem 0.625rem; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; font-size: 0.875rem; color: var(--gray-700); text-align: left; cursor: pointer; }
.dp-call-menu button:hover { background: var(--gray-50); color: var(--gray-900); }
.pd-split #pd-start-btn { display: inline-flex; align-items: center; gap: 0.5rem; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.pd-split .pd-gear { border-top-left-radius: 0; border-bottom-left-radius: 0; border-left: 1px solid rgba(255,255,255,0.35); padding-left: 0.625rem; padding-right: 0.625rem; display: inline-flex; align-items: center; }
#pd-start-btn.pd-running { background: var(--success); border-color: var(--success); }
#pd-start-btn.pd-running + .pd-gear { background: var(--success); border-color: var(--success); }
#pd-start-btn.pd-error, #pd-start-btn.pd-error + .pd-gear { background: var(--danger); border-color: var(--danger); }
.pd-card-error { border-color: #fecaca; }
.pd-problem { margin-top: 0.5rem; padding: 0.5rem 0.625rem; border-radius: var(--radius-sm); background: #fee2e2; color: #991b1b; font-size: 0.8125rem; overflow-wrap: anywhere; }
.pd-card { border: 1px solid #dbeafe; background: #fff; border-radius: var(--radius-lg); padding: 0.875rem 1rem; margin-bottom: 0.875rem; box-shadow: 0 1px 2px rgba(16,24,40,0.04); }
.pd-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.pd-who b { display: block; font-size: 1rem; color: var(--gray-900); }
.pd-who span { display: inline-flex; align-items: center; gap: 0.375rem; font-size: 0.8125rem; color: var(--gray-500); }
.pd-timer { display: inline-flex; align-items: center; height: 30px; padding: 0 0.75rem; border-radius: 999px; background: var(--gray-100); color: var(--gray-700); font-weight: 700; font-variant-numeric: tabular-nums; }
.pd-timer.ringing { background: #fef3c7; color: #b45309; }
.pd-timer.live { background: #fee2e2; color: #dc2626; }
.pd-status { margin-top: 0.5rem; font-size: 0.8125rem; color: var(--gray-600); }
.pd-mini { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; font-size: 0.8125rem; color: var(--gray-700); }
.pd-state { padding: 0.625rem 0.75rem; border-radius: var(--radius); font-size: 0.8125rem; margin-bottom: 1rem; }
.pd-state.ok { background: #dcfce7; color: #166534; }
.pd-state.warn { background: #fef3c7; color: #92400e; }
.pd-state small { color: inherit; opacity: 0.85; }
#pd-start-btn.pd-paused, #pd-start-btn.pd-paused + .pd-gear { background: var(--warning); border-color: var(--warning); }
.pd-warn { margin-top: 0.5rem; padding: 0.375rem 0.625rem; border-radius: var(--radius-sm); background: #fef3c7; color: #92400e; font-size: 0.75rem; }
.pd-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.75rem; }
.pd-actions .pd-stop { margin-left: auto; color: var(--danger); }
.pd-label { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gray-400); margin-bottom: 0.5rem; }
.pd-next { display: flex; align-items: center; gap: 0.875rem; padding: 0.75rem 0.875rem; border: 1px solid #dbeafe; border-radius: var(--radius); background: var(--primary-soft); }
.pd-next-icon { width: 38px; height: 38px; border-radius: 50%; background: #fff; color: var(--primary); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pd-next-text { min-width: 0; flex: 1; }
.pd-next-text b { display: block; color: var(--gray-900); }
.pd-next-text span { font-size: 0.8125rem; color: var(--gray-500); }
.pd-go { position: relative; overflow: hidden; height: 36px; min-width: 190px; padding: 0 1rem; border: none; border-radius: 999px; background: #93c5fd; color: #fff; font: inherit; font-size: 0.875rem; font-weight: 700; cursor: pointer; flex-shrink: 0; }
.pd-go-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--primary); transition: width 1s linear; }
.pd-go-label { position: relative; display: inline-flex; align-items: center; gap: 0.5rem; color: #fff; text-shadow: 0 1px 1px rgba(30,58,138,0.25); }
.pd-go:hover .pd-go-label { text-decoration: underline; }
@media (max-width: 640px) { .pd-next { flex-wrap: wrap; } .pd-go { width: 100%; } }

/* ===== Termine ===== */
.calllog-appt { padding: 0.75rem; border: 1px solid #dbeafe; border-radius: var(--radius); background: var(--primary-soft); }
.calllog-appt .form-input, .calllog-appt .form-select { background-color: #fff; }
.calllog-appt .calllog-when { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.calllog-appt .calllog-when > * { min-width: 0; width: 100%; }
.calllog-appt-row { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem 0.75rem; margin-bottom: 0.5rem; }
.lead-appts { margin-top: 0.75rem; display: flex; flex-direction: column; gap: 0.375rem; }
.lead-appt { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; font-size: 0.8125rem; color: var(--gray-700); }
.dp-appt { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0.5rem 0.75rem; margin-top: 0.625rem; border-radius: var(--radius-sm); background: #fff; border: 1px solid #dbeafe; font-size: 0.8125rem; color: var(--gray-700); }
.dp-appt.due { border-color: #fcd34d; background: #fffbeb; }
.appt-table td { vertical-align: middle; }
.appt-badge { display: inline-flex; align-items: center; height: 22px; padding: 0 0.5rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; background: var(--gray-100); color: var(--gray-700); }
.appt-badge.setting { background: #dbeafe; color: #1d4ed8; }
.appt-badge.closing { background: #ede9fe; color: #6d28d9; }
.nav-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--warning); color: #fff; font-size: 0.6875rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }

/* ===== Nächste Termine (Seitenleiste) ===== */
.up-appts { margin: 0 var(--space-3) var(--space-3); padding: 0.625rem; border: 1px solid var(--gray-100); border-radius: var(--radius); background: var(--gray-50); }
.up-title { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gray-400); margin-bottom: 0.375rem; }
.up-item { padding: 0.5rem; border-radius: var(--radius-sm); background: #fff; border: 1px solid var(--gray-100); margin-bottom: 0.375rem; }
.up-item:last-of-type { margin-bottom: 0; }
.up-item.soon { border-color: #fcd34d; background: #fffbeb; }
.up-item.live { border-color: #86efac; background: #f0fdf4; }
.up-time { display: flex; align-items: center; justify-content: space-between; gap: 0.375rem; font-size: 0.75rem; font-weight: 600; color: var(--gray-600); }
.up-item.soon .up-time { color: #b45309; }
.up-item.live .up-time { color: #15803d; }
.up-time .appt-badge { height: 18px; font-size: 0.625rem; padding: 0 0.375rem; }
.up-name { display: block; margin: 0.125rem 0 0.375rem; font-size: 0.8125rem; font-weight: 600; color: var(--gray-900); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-name:hover { text-decoration: underline; }
.up-actions { display: flex; align-items: center; justify-content: space-between; gap: 0.375rem; }
.up-btn { display: inline-flex; align-items: center; gap: 0.375rem; min-width: 0; height: 26px; padding: 0 0.5rem; border-radius: var(--radius-sm); background: var(--primary); color: #fff; font-size: 0.75rem; font-weight: 600; text-decoration: none; white-space: nowrap; overflow: hidden; }
.up-btn:hover { background: var(--primary-dark); }
.up-loc { font-size: 0.75rem; color: var(--gray-600); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up-link { font-size: 0.75rem; font-weight: 600; color: var(--primary-dark); text-decoration: none; }
.up-more { display: block; margin-top: 0.375rem; font-size: 0.75rem; color: var(--gray-500); text-decoration: none; text-align: center; }
.up-appts[hidden] { display: none; }
.nav-item.has-soon .nav-icon { position: relative; }
.nav-item.has-soon .nav-icon::after { content: ''; position: absolute; top: -2px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 2px #fff; animation: repCalling 1.6s ease-out infinite; }

/* Eingehende Anrufe (incoming-call.js) */
.ic-stack { position: fixed; right: 1rem; bottom: 1rem; z-index: 1200; display: flex; flex-direction: column; gap: 0.5rem; width: min(340px, calc(100vw - 2rem)); }
.ic-card { background: #fff; border: 1px solid var(--gray-100); border-left: 4px solid var(--gray-300); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15); padding: 0.75rem 0.875rem; }
.ic-card.ic-ringing { border-left-color: #22c55e; animation: ic-pulse 1.2s ease-in-out infinite; }
.ic-card.ic-talking { border-left-color: #3b82f6; }
.ic-card.ic-done { border-left-color: var(--gray-400); }
@keyframes ic-pulse { 0%, 100% { box-shadow: 0 10px 30px rgba(15, 23, 42, 0.15); } 50% { box-shadow: 0 10px 30px rgba(34, 197, 94, 0.35); } }
.ic-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.25rem; }
.ic-label { font-size: 0.6875rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--gray-500); }
.ic-ringing .ic-label { color: #15803d; }
.ic-close { border: 0; background: none; font-size: 1.125rem; line-height: 1; color: var(--gray-400); cursor: pointer; padding: 0 0.125rem; }
.ic-who b { display: block; font-size: 0.9375rem; color: var(--gray-900); }
.ic-who span { display: block; font-size: 0.8125rem; color: var(--gray-600); }
.ic-num, .ic-meta, .ic-last { font-size: 0.75rem; color: var(--gray-500); margin-top: 0.125rem; }
.ic-last { color: var(--gray-700); }
.ic-actions { display: flex; gap: 0.375rem; margin-top: 0.625rem; }
.ic-actions:empty { display: none; }
.mc-item { border-color: #fecaca; background: #fef2f2; }
.mc-item .up-time { color: #b91c1c; }
.mc-done { border: 0; background: none; padding: 0; cursor: pointer; font: inherit; }

/* Neuer Lead (Pipeline) */
.nl-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
@media (max-width: 520px) { .nl-row { grid-template-columns: 1fr; gap: 0; } }
.nl-dupes { margin: -0.25rem 0 1rem; padding: 0.625rem 0.75rem; border: 1px solid #fcd34d; background: #fffbeb; border-radius: var(--radius-sm); font-size: 0.8125rem; color: #92400e; }
.nl-dupe { margin-top: 0.25rem; }
.nl-dupe a { color: #92400e; font-weight: 600; }
.nl-dupe span { color: #b45309; }

/* ===== Pipeline-Liste (Karte mit Werkzeugleiste, Reitern, Tabelle, Paginierung) ===== */
.pl-title { display: flex; align-items: baseline; gap: 0.75rem; flex-wrap: wrap; min-width: 0; }
.pl-count { font-size: 0.9375rem; color: var(--gray-500); font-weight: 500; white-space: nowrap; }
.pl-card { overflow: visible; }
.pl-toolbar { flex-wrap: wrap; margin: 0; padding: var(--space-4) var(--space-4) var(--space-3); }
.pl-toolbar .search-input-wrap { flex: 1 1 220px; max-width: 320px; }
.pl-toolbar .search-input-wrap input { background: var(--gray-50); }
.pl-toolbar .search-input-wrap input:focus { background: #fff; }
.pl-title .wl-bar { margin-left: var(--space-2); align-self: center; }
.pl-toolbar-end { margin-left: auto; display: flex; align-items: center; gap: var(--space-2); }
.pl-toolbar-end .btn { display: inline-flex; align-items: center; gap: 0.375rem; }
.pl-filter-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--primary); }
.pl-menu { padding: 0.375rem; min-width: 210px; }
.pl-menu button { display: block; width: 100%; text-align: left; padding: 0.5rem 0.625rem; border: 0; background: none; border-radius: var(--radius-sm); font: inherit; font-size: 0.875rem; color: var(--gray-700); cursor: pointer; }
.pl-menu button:hover { background: var(--gray-50); }
.pl-menu .pl-menu-danger { color: #b91c1c; }
.pl-menu .pl-menu-danger:hover { background: #fef2f2; }
.pl-menu-sep { height: 1px; background: var(--gray-100); margin: 0.25rem 0; }

.pl-tabs { margin: 0; padding: 0 var(--space-4); gap: 0.25rem; scrollbar-width: thin; }
.pl-tabs .stage-tab { padding: 0.625rem 0.75rem; font-weight: 500; border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.pl-tabs .stage-tab:hover { background: var(--gray-50); }
.pl-tabs .stage-tab.active { font-weight: 600; background: var(--primary-soft); color: var(--gray-900); }
.pl-tab-count { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 20px; padding: 0 0.4375rem; border-radius: 999px; font-size: 0.6875rem; font-weight: 700; background: var(--gray-100); color: var(--gray-500); font-variant-numeric: tabular-nums; }

.pl-table th { background: #fff; border-radius: 0 !important; }
.pl-table td { padding: 0.625rem 1.25rem; font-size: 0.875rem; color: var(--gray-700); white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.pl-table tbody tr { cursor: pointer; }
.pl-table tbody tr.selected td:first-child { box-shadow: inset 3px 0 0 var(--primary); }
#deal-table-body.pl-loading { opacity: 0.55; transition: opacity 0.15s; }
.pl-name { font-weight: 500; color: var(--gray-900); overflow: hidden; text-overflow: ellipsis; }
.pl-company { color: var(--gray-600); }
.pl-muted { color: var(--gray-400); }
.pl-nowrap { white-space: nowrap; }
.pl-link { color: var(--primary-dark); text-decoration: none; }
.pl-link:hover { text-decoration: underline; }
.pl-phone { font-variant-numeric: tabular-nums; }
.pl-chip { display: inline-flex; align-items: center; gap: 0.3125rem; height: 24px; padding: 0 0.5rem; border-radius: 999px; background: var(--gray-100); color: var(--gray-600); font-size: 0.75rem; font-weight: 500; }
.pl-empty { padding: 3rem 1rem !important; text-align: center; color: var(--gray-400) !important; white-space: normal !important; }

.pl-pagination { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1rem; padding: 0.625rem var(--space-4); border-top: 1px solid var(--gray-100); font-size: 0.8125rem; color: var(--gray-500); }
.pl-pagination-right { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pl-page-size { display: inline-flex; align-items: center; gap: 0.5rem; white-space: nowrap; }
.pl-page-size select { width: auto; min-width: 64px; height: 30px; padding: 0 0.5rem; border: 1px solid var(--gray-300); border-radius: var(--radius-sm); background: #fff; font: inherit; color: var(--gray-700); }
.pl-page-btns { display: flex; align-items: center; gap: 0.25rem; }
.pl-page-btn { min-width: 30px; height: 30px; padding: 0 0.5rem; border: 1px solid transparent; background: none; border-radius: var(--radius-sm); font: inherit; color: var(--gray-600); cursor: pointer; font-variant-numeric: tabular-nums; }
.pl-page-btn:hover:not(:disabled) { background: var(--gray-100); }
.pl-page-btn.active { background: var(--primary); color: #fff; }
.pl-page-btn:disabled { opacity: 0.35; cursor: default; }
.pl-page-gap { padding: 0 0.25rem; color: var(--gray-400); }
@media (max-width: 640px) {
  .pl-toolbar-end { margin-left: 0; width: 100%; }
  .pl-toolbar-end .btn { flex: 1; justify-content: center; }
}

/* Anruf-Formular: Lead steht in einer Phase ohne Gesprächstyp */
.calllog-stage-warn { margin-top: 0.375rem; padding: 0.375rem 0.625rem; border-radius: var(--radius-sm); background: #fef3c7; color: #92400e; font-size: 0.75rem; line-height: 1.4; }


/* ===== Handy: nur das Nötigste (telefonieren, suchen, filtern, Lead anlegen) – Verwaltung bleibt am Desktop =====
 * Ausgeblendet wird nach Breite, nicht nach Gerät: Tablet quer oder breites Fenster bekommen alles.
 * Nur die Oberfläche – Rechte und API bleiben unverändert. */
.desktop-hint { display: none; }
.mobile-only { display: none !important; }
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: revert !important; }
  .page-desktop-only > :not(.desktop-hint) { display: none !important; }
  .page-desktop-only > .desktop-hint {
    display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
    margin: 3rem auto; max-width: 320px; text-align: center; color: var(--gray-500);
  }
  .desktop-hint svg { color: var(--gray-400); }
  .desktop-hint b { font-size: 1.0625rem; color: var(--gray-900); }
  .desktop-hint .btn { margin-top: 0.75rem; }
}
@media (max-width: 768px) {
  /* Pipeline: Suche, Filter und „+“ in einer Zeile */
  .pl-toolbar { flex-wrap: nowrap; gap: 0.5rem; padding: 0.75rem; }
  .pl-toolbar .search-input-wrap { flex: 1 1 auto; max-width: none; min-width: 0; }
  .pl-toolbar-end { margin-left: 0; width: auto; flex-shrink: 0; }
  .pl-toolbar-end .btn { flex: 0 0 auto; }
  .pl-new-btn { width: var(--control-height, 38px); padding: 0; justify-content: center; }
  .pl-new-btn .pl-btn-label { display: none; }
  .pl-owner-slot #owner-filter { display: block; width: calc(100% - 1.5rem); max-width: none !important; margin: 0.5rem 0.75rem; }
  .pl-sheet-done { padding: 0.5rem 0.75rem 0.25rem; }
  .pl-sheet-done .btn { width: 100%; justify-content: center; }
  /* Der Power-Dialer-Kasten liegt fest unten – oben bleibt kein leerer Platz */
  .page-header:has(.pd-dock) { margin-bottom: var(--space-3); }
  .page-header:has(.pd-dock) .page-actions { margin: 0; min-height: 0; padding: 0; }
}
/* Pipeline am Handy: Karten statt Tabelle */
.pl-card-row { display: flex; align-items: center; gap: 0.75rem; padding: 0.75rem 0.875rem; border-top: 1px solid var(--gray-100); cursor: pointer; }
.pl-card-row:active { background: var(--gray-50); }
.pl-card-row.selected { box-shadow: inset 3px 0 0 var(--primary); background: #f8fbff; }
.pl-card-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.125rem; }
.pl-card-main b { font-size: 0.9375rem; font-weight: 600; color: var(--gray-900); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-card-sub { display: flex; align-items: center; font-size: 0.8125rem; color: var(--gray-500); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl-card-sub .rep-dot { width: 18px; height: 18px; margin-right: 0.375rem; font-size: 0.5rem; }
.pl-card-call { display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; width: 42px; height: 42px; border-radius: 50%; background: #eff6ff; color: var(--primary); }
.pl-card-call:active { background: #dbeafe; }
.pl-cards .pl-empty { padding: 2rem 1rem; text-align: center; color: var(--gray-400); }
/* Lead-Panel: Menü am Zahnrad neben „Anrufen“ (Power-Dialer, Gerät, Anruf loggen, Einstellungen) */
.dp-split .dp-caret svg { display: block; }
.pd-menu { left: auto; right: 0; min-width: 280px; padding: 0.5rem; }
.pd-menu-auto { display: flex; align-items: center; gap: 0.625rem; padding: 0.625rem 0.75rem; border-radius: var(--radius); background: #eff6ff; cursor: pointer; }
.pd-menu-auto.is-off { background: var(--gray-50); }
.pd-menu-auto-icon { display: inline-flex; color: var(--primary); }
.pd-menu-auto.is-off .pd-menu-auto-icon { color: var(--gray-400); }
.pd-menu-auto-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.pd-menu-auto-text b { font-size: 0.875rem; color: var(--primary-dark, #1d4ed8); }
.pd-menu-auto.is-off .pd-menu-auto-text b { color: var(--gray-700); }
.pd-menu-auto-text small { font-size: 0.75rem; color: var(--gray-500); }
.pd-switch { appearance: none; -webkit-appearance: none; position: relative; flex-shrink: 0; width: 36px; height: 20px; margin: 0; border-radius: 999px; background: var(--gray-300); cursor: pointer; transition: background 0.15s; }
.pd-switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,0.2); transition: transform 0.15s; }
.pd-switch:checked { background: var(--primary); }
.pd-switch:checked::after { transform: translateX(16px); }
.pd-switch:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.pd-menu-label { margin: 0.625rem 0.625rem 0.25rem; font-size: 0.6875rem; font-weight: 700; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.05em; }
.dp-call-menu .pd-menu-device, .dp-call-menu button { display: flex; align-items: center; gap: 0.5rem; }
.pd-menu-device span { flex: 1; }
.dp-call-menu .pd-menu-device.is-active { background: #ecfdf5; color: var(--gray-900); }
.dp-call-menu .pd-menu-device.is-active svg:last-child:not(:first-child) { color: #16a34a; }
.pd-menu-device.is-static { padding: 0.5rem 0.625rem; border-radius: var(--radius-sm); font-size: 0.875rem; }
.pd-menu-sep { height: 1px; margin: 0.375rem 0; background: var(--gray-100); }
/* Handy: solange das Menü offen ist, verdeckt der Startknopf-Kasten es nicht */
@media (max-width: 768px) { body:has(#dp-call-menu:not([hidden])) .page-actions .pd-dock { display: none !important; } }
@media (max-width: 768px) { .pd-menu { position: fixed; top: auto; left: var(--space-3); right: var(--space-3); bottom: var(--space-3); min-width: 0; z-index: 1050; box-shadow: 0 -8px 32px rgba(16,24,40,0.22); } }
/* Zahnrad-Menü am Startknopf oben: unter dem Knopf, rechtsbündig */
.pd-split { position: relative; }
#pd-dock-menu { top: calc(100% + 6px); right: 0; left: auto; z-index: 960; }
@media (max-width: 768px) { #pd-dock-menu { top: auto; left: var(--space-3); right: var(--space-3); z-index: 1050; } }
/* Phasen-Reiter: mindestens so breit wie ihr Name, der Rest der Breite wird verteilt; zu viele -> waagrecht scrollen */
.pl-tabs { gap: 0.375rem; padding: 0 var(--space-4); border-bottom: 1px solid var(--gray-200); }
.pl-tabs .stage-tab { flex: 1 0 auto; justify-content: space-between; gap: 0.5rem; padding: 0.625rem 0.875rem;
  border: 1px solid var(--gray-200); border-bottom: 0; border-radius: var(--radius) var(--radius) 0 0; background: var(--gray-50); color: var(--gray-600); }
.pl-tabs .stage-tab:hover { background: #fff; color: var(--gray-900); }
.pl-tabs .stage-tab.active { background: var(--primary-soft); border-color: transparent; color: var(--gray-900); box-shadow: inset 0 -2px 0 var(--primary); }
@media (max-width: 768px) {
  .pl-tabs .stage-tab { flex: 0 0 auto; }
}
