/* Aqua Treatments — Lead-Portal (Fluid-Responsive: 320 px → 4K) */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --cyan: #3CAAC8;
  --cyan-dark: #0F5F82;
  --orange: #F39200;
  --orange-dark: #C9760A;
  --gray-50: #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-300: #CBD5E1;
  --gray-500: #64748B;
  --gray-700: #334155;
  --gray-900: #0F172A;
  --green: #10B981;
  --red: #EF4444;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.05);
  --shadow-md: 0 4px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.12);

  /* Fluid tokens — skalieren mit Viewport ohne harte Breakpoints */
  --pad-x: clamp(12px, 2.5vw, 24px);
  --pad-y: clamp(10px, 1.6vw, 18px);
  --gap:   clamp(8px,  1.2vw, 16px);
  --radius:    clamp(10px, 1vw, 14px);
  --radius-lg: clamp(14px, 1.4vw, 20px);
  --fs-stat-val:   clamp(16px, 1.2vw + 12px, 26px);
  --fs-stat-label: clamp(9px,  .25vw + 8px,  11px);
  --fs-card-name:  clamp(14px, .25vw + 13px, 16px);
  --fs-card-tag:   clamp(10px, .15vw + 10px, 12px);
  --fs-col-title:  clamp(11px, .2vw + 10px,  13px);
  --fs-detail-h2:  clamp(20px, 1.4vw + 14px, 28px);
  --fs-btn:        clamp(13px, .25vw + 12px, 15px);
  --tap-min: 44px;

  --safe-top: env(safe-area-inset-top, 0);
  --safe-bot: env(safe-area-inset-bottom, 0);
}

html, body {
  font-family: 'Inter Display', Inter, -apple-system, system-ui, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  text-size-adjust: 100%;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 0;
  font-size: 14px;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}

/* ── Brand ── */
.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
}
.brand-mark {
  font-size: clamp(8px, .12vw + 7px, 10px);
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--cyan);
  align-self: flex-start;
  margin-top: 4px;
  white-space: nowrap;
}
.brand-name {
  font-size: clamp(16px, 1vw + 12px, 24px);
  font-weight: 600;
  color: var(--cyan);
  white-space: nowrap;
}
.brand-name b { color: var(--cyan-dark); font-weight: 800; }

/* ── Login ── */
.login-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--cyan-dark), #0a3a55);
  display: grid;
  place-items: center;
  padding: clamp(16px, 4vw, 32px);
  padding-top: max(16px, var(--safe-top));
  padding-bottom: max(16px, var(--safe-bot));
}
.login-card {
  background: white;
  padding: clamp(24px, 4vw, 40px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}
.login-card .brand { margin-bottom: clamp(18px, 2vw, 28px); }
.login-card h1 {
  font-size: clamp(20px, 1vw + 16px, 26px);
  font-weight: 800;
  margin-bottom: 6px;
}
.login-card .subtitle {
  color: var(--gray-500);
  font-size: clamp(13px, .25vw + 12px, 15px);
  margin-bottom: clamp(16px, 2vw, 24px);
}
.login-card form { display: flex; flex-direction: column; gap: 10px; }
.login-card input {
  font-family: inherit;
  padding: 14px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--gray-200);
  font-size: 16px;
  outline: none;
  transition: border .15s;
  width: 100%;
  min-height: var(--tap-min);
}
.login-card input:focus { border-color: var(--cyan); }
.login-card button {
  background: var(--cyan);
  color: white;
  padding: 14px;
  border-radius: 12px;
  font-size: clamp(14px, .25vw + 13px, 16px);
  font-weight: 700;
  min-height: 48px;
}
.login-card button:hover { background: var(--cyan-dark); }
.err {
  color: var(--red);
  font-size: 13px;
  margin-top: 10px;
  min-height: 18px;
}

/* ── Topbar ── */
.topbar {
  background: white;
  border-bottom: 1px solid var(--gray-200);
  position: sticky;
  top: 0;
  z-index: 10;
  padding-top: var(--safe-top);
}
.topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gap);
  padding: clamp(10px, 1.2vw, 16px) var(--pad-x);
}
.actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}
.btn-icon {
  width: var(--tap-min);
  height: var(--tap-min);
  background: var(--gray-100);
  color: var(--gray-700);
  border-radius: 10px;
  font-size: 18px;
  display: grid;
  place-items: center;
}
.btn-ghost {
  background: var(--gray-100);
  color: var(--gray-700);
  padding: 0 14px;
  border-radius: 10px;
  font-size: clamp(12px, .15vw + 11px, 14px);
  min-height: var(--tap-min);
}
.btn-ghost:hover, .btn-icon:hover { background: var(--gray-200); }

/* Stats — auto-fit Grid skaliert von 1 bis 4 Spalten je nach Breite */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(80px, 18vw, 120px), 1fr));
  gap: clamp(6px, 1vw, 16px);
  padding: 0 var(--pad-x) clamp(8px, 1vw, 14px);
  border-bottom: 1px solid var(--gray-100);
}
.stat {
  background: var(--gray-50);
  border-radius: 10px;
  padding: clamp(6px, .8vw, 12px) clamp(8px, 1vw, 14px);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.stat-label {
  font-size: var(--fs-stat-label);
  text-transform: uppercase;
  color: var(--gray-500);
  font-weight: 700;
  letter-spacing: .5px;
}
.stat-val {
  font-size: var(--fs-stat-val);
  font-weight: 800;
  color: var(--gray-900);
  line-height: 1;
}

/* Tabs — horizontal scrollable, fluid font/padding */
.tabs {
  display: flex;
  gap: 6px;
  padding: clamp(8px, 1vw, 12px) var(--pad-x);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: clamp(12px, .2vw + 11px, 14px);
  font-weight: 700;
  white-space: nowrap;
  border: 1.5px solid transparent;
  min-height: 36px;
}
.tab.active {
  background: var(--gray-900);
  color: white;
}
.tab .tab-dot { width: 8px; height: 8px; border-radius: 4px; flex-shrink: 0; }
.tab .tab-count {
  background: rgba(0,0,0,.08);
  border-radius: 8px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 800;
}
.tab.active .tab-count { background: rgba(255,255,255,.18); color: white; }

/* ── Kanban — fluid auto-fit, 1 Spalte (Mobile) → 6 Spalten (Desktop) ────
   Mobile zeigt JS-controlled nur eine Spalte via .col[hidden].
   Bei mind. 600 px Breite zeigt JS alle Spalten und auto-fit übernimmt. */
.kanban {
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(10px, 1.2vw, 16px);
  padding: clamp(10px, 1.5vw, 20px) var(--pad-x) max(16px, var(--safe-bot));
}
.kanban.desktop-mode {
  grid-template-columns: repeat(auto-fit, minmax(clamp(220px, 18vw, 280px), 1fr));
  align-items: start;
  overflow-x: auto;
}

.col {
  background: var(--gray-100);
  border-radius: var(--radius);
  padding: clamp(10px, 1vw, 14px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: clamp(100px, 12vw, 240px);
}
.col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2px 4px;
}
.col-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-col-title);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-700);
}
.dot { width: 8px; height: 8px; border-radius: 4px; flex-shrink: 0; }
.col[data-status="neu"]          .dot, .tab[data-status="neu"]          .tab-dot { background: var(--cyan); }
.col[data-status="kontaktiert"]  .dot, .tab[data-status="kontaktiert"]  .tab-dot { background: #6366F1; }
.col[data-status="termin"]       .dot, .tab[data-status="termin"]       .tab-dot { background: #F59E0B; }
.col[data-status="wassertest"]   .dot, .tab[data-status="wassertest"]   .tab-dot { background: #8B5CF6; }
.col[data-status="verkauft"]     .dot, .tab[data-status="verkauft"]     .tab-dot { background: var(--green); }
.col[data-status="verloren"]     .dot, .tab[data-status="verloren"]     .tab-dot { background: var(--red); }
.col-count {
  background: white;
  border-radius: 10px;
  padding: 2px 9px;
  font-size: clamp(11px, .15vw + 10px, 13px);
  font-weight: 800;
  color: var(--gray-700);
  box-shadow: var(--shadow-sm);
}

/* Drag-over (Desktop) */
.kanban.desktop-mode .col.drag-over {
  background: #E0F2F1;
  outline: 2px dashed var(--cyan);
  outline-offset: -4px;
}

/* ── Lead Card ── */
.card {
  background: white;
  border-radius: var(--radius);
  padding: clamp(10px, 1vw, 14px) clamp(12px, 1.2vw, 16px);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: transform .12s, box-shadow .12s;
  border-left: 3px solid var(--cyan);
  min-height: var(--tap-min);
}
.card[data-haerte-class="weich"] { border-left-color: var(--green); }
.card[data-haerte-class="mittel"] { border-left-color: #F59E0B; }
.card[data-haerte-class="hart"] { border-left-color: var(--orange); }
.card[data-haerte-class="sehr-hart"] { border-left-color: var(--red); }
.card:active { transform: scale(.99); }
.card.dragging { opacity: .5; }
.kanban.desktop-mode .card { cursor: grab; }
.kanban.desktop-mode .card:active { cursor: grabbing; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.card-name {
  font-weight: 700;
  font-size: var(--fs-card-name);
  color: var(--gray-900);
  word-break: break-word;
}
.card-time {
  font-size: clamp(10px, .12vw + 9px, 12px);
  color: var(--gray-500);
  flex-shrink: 0;
}
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}
.tag {
  font-size: var(--fs-card-tag);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
  background: var(--gray-100);
  color: var(--gray-700);
}
.tag.haerte { background: #FEF3C7; color: #92400E; }
.tag.haerte.weich { background: #D1FAE5; color: #065F46; }
.tag.haerte.sehr-hart { background: #FEE2E2; color: #991B1B; }
.tag.utm { background: #EEF2FF; color: #3730A3; }
.card-line {
  font-size: clamp(11px, .15vw + 10px, 13px);
  color: var(--gray-500);
  margin-top: 3px;
  word-break: break-word;
}
.card-line .label { color: var(--gray-700); font-weight: 700; }

.empty {
  text-align: center;
  color: var(--gray-500);
  font-size: clamp(12px, .15vw + 11px, 14px);
  padding: clamp(20px, 3vw, 32px) 16px;
  border-radius: 10px;
  border: 1.5px dashed var(--gray-300);
}

/* ── Modal — Mobile full-screen, ab ~600 px zentriert ── */
.lead-modal {
  border: 0;
  padding: 0;
  background: white;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 100%;
  height: 100%;
  max-height: 100%;
  border-radius: 0;
  margin: 0;
}
@media (min-width: 600px) {
  .lead-modal {
    width: min(560px, 92vw);
    max-width: 92vw;
    height: auto;
    max-height: 88vh;
    border-radius: var(--radius-lg);
    margin: auto;
  }
  .lead-modal .close {
    position: absolute !important;
    top: 14px !important;
  }
}
.lead-modal::backdrop { background: rgba(15,23,42,.5); }
.lead-modal .close {
  position: fixed;
  top: max(12px, var(--safe-top));
  right: 12px;
  background: var(--gray-100);
  color: var(--gray-700);
  width: 40px;
  height: 40px;
  border-radius: 20px;
  font-size: 20px;
  z-index: 10;
  display: grid;
  place-items: center;
}
#lead-detail {
  padding: clamp(48px, 7vw, 64px) clamp(16px, 3vw, 32px) max(28px, var(--safe-bot));
}
#lead-detail h2 {
  font-size: var(--fs-detail-h2);
  font-weight: 800;
  margin-bottom: 4px;
  word-break: break-word;
}
#lead-detail .detail-time {
  font-size: clamp(12px, .15vw + 11px, 14px);
  color: var(--gray-500);
  margin-bottom: clamp(16px, 2vw, 24px);
}

/* Detail-Grid: auto-fit, mind. 140 px je Spalte */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: clamp(10px, 1.2vw, 14px);
  margin-bottom: clamp(18px, 2.4vw, 28px);
}
.detail-grid .field-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  font-weight: 700;
}
.detail-grid .field-value {
  font-size: clamp(13px, .2vw + 12px, 15px);
  color: var(--gray-900);
  font-weight: 700;
  word-break: break-word;
  margin-top: 2px;
}

/* Quelle field full-width */
.detail-grid .field-full { grid-column: 1 / -1; }

.call-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: clamp(16px, 2vw, 24px);
}
.call-row a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(12px, 1.4vw, 16px);
  border-radius: 12px;
  font-weight: 700;
  font-size: var(--fs-btn);
  text-decoration: none;
  min-height: 48px;
  background: var(--cyan);
  color: white;
}
.call-row a.wa { background: #25D366; }
.call-row a:hover { filter: brightness(.95); }

/* Status-Actions: auto-fit Grid (2 → 3 → 6 Spalten je nach Breite) */
.detail-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: clamp(14px, 1.8vw, 20px);
}
.detail-actions .status-btn {
  padding: clamp(10px, 1.2vw, 14px) 8px;
  border-radius: 10px;
  font-size: clamp(11px, .15vw + 10px, 13px);
  font-weight: 800;
  background: var(--gray-100);
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: .3px;
  min-height: var(--tap-min);
}
.detail-actions .status-btn:hover { background: var(--gray-200); }
.detail-actions .status-btn.active {
  background: var(--cyan);
  color: white;
}

.notizen-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  font-weight: 700;
  display: block;
  margin-bottom: 8px;
}
.notizen-area {
  width: 100%;
  min-height: clamp(90px, 12vh, 140px);
  padding: 14px;
  border-radius: 12px;
  border: 1.5px solid var(--gray-200);
  font-family: inherit;
  font-size: 16px;
  resize: vertical;
  outline: none;
}
.notizen-area:focus { border-color: var(--cyan); }
.save-btn {
  background: var(--orange);
  color: white;
  padding: 14px 20px;
  border-radius: 12px;
  font-weight: 800;
  margin-top: 14px;
  width: 100%;
  font-size: var(--fs-btn);
  min-height: 48px;
}
.save-btn:hover { background: var(--orange-dark); }
.delete-btn {
  background: transparent;
  color: var(--red);
  padding: 12px;
  border-radius: 10px;
  font-size: clamp(12px, .15vw + 11px, 14px);
  font-weight: 700;
  margin-top: 12px;
  width: 100%;
  min-height: var(--tap-min);
}
.delete-btn:hover { background: #FEF2F2; }
