/* ===============================================================
   CTM Lead-Dashboard – UI Design System
   Warm, einladend, intuitiv · Navy + Gold (CTM-Branding)
   =============================================================== */

/* ── Fonts (lokal, DSGVO-konform) ─────────────────────────── */
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 400; font-display: swap;
  src: url('/fonts/inter-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 500; font-display: swap;
  src: url('/fonts/inter-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Inter';
  font-style: normal; font-weight: 600; font-display: swap;
  src: url('/fonts/inter-latin-600-normal.woff2') format('woff2');
}

:root {
  /* Brand */
  --gold: #FFD700;
  --gold-2: #FFA500;
  --gold-3: #FF8C00;
  --gradient-gold: linear-gradient(135deg, #FFD700 0%, #FFA500 55%, #FF8C00 100%);

  /* Surfaces */
  --bg: #0b1524;
  --bg-mesh:
    radial-gradient(900px 600px at 12% -5%, rgba(255, 215, 0, 0.10) 0%, transparent 55%),
    radial-gradient(1000px 700px at 100% 0%, rgba(56, 132, 255, 0.12) 0%, transparent 55%),
    radial-gradient(700px 700px at 60% 110%, rgba(45, 212, 191, 0.06) 0%, transparent 55%);
  --surface: rgba(255, 255, 255, 0.035);
  --surface-2: rgba(255, 255, 255, 0.06);
  --surface-hover: rgba(255, 215, 0, 0.06);
  --card: rgba(17, 27, 44, 0.72);
  --border: rgba(255, 255, 255, 0.09);
  --border-2: rgba(255, 255, 255, 0.14);
  --border-gold: rgba(255, 215, 0, 0.42);

  /* Text */
  --text: #eef2f8;
  --text-soft: #c4cede;
  --muted: #8b98af;

  /* Status */
  --st-neu: #38bdf8;
  --st-angerufen: #fbbf24;
  --st-kein: #fb7185;
  --st-qual: #a78bfa;
  --st-termin: #34d399;

  /* Radius & shadow */
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --r-xl: 28px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
  --shadow-lg: 0 20px 55px rgba(0, 0, 0, 0.42);
  --glow-gold: 0 6px 22px rgba(255, 176, 32, 0.35);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  background-image: var(--bg-mesh);
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.error { color: var(--st-kein); font-size: 0.9rem; min-height: 1.1em; }

svg.ico { width: 1em; height: 1em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ── Login ────────────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  background: var(--bg); background-image: var(--bg-mesh);
}
.login-card {
  width: 400px; max-width: 100%;
  background: var(--card);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  padding: 44px 38px;
  text-align: center;
  display: flex; flex-direction: column; gap: 16px;
  animation: pop 0.4s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(0.98); } to { opacity: 1; transform: none; } }
.login-logo { width: 172px; max-width: 66%; margin: 0 auto 4px; height: auto; }
.login-card h1 { font-size: 1.55rem; font-weight: 600; letter-spacing: -0.02em; }
.login-card .sub { color: var(--muted); font-size: 0.9rem; margin-top: -8px; }
.login-card input {
  width: 100%; padding: 14px 16px; border-radius: var(--r-sm);
  font-size: 1rem; font-family: inherit;
  background: rgba(255, 255, 255, 0.05); color: var(--text);
  border: 1px solid var(--border-2); transition: all 0.2s ease;
}
.login-card input:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.14);
  background: rgba(255, 255, 255, 0.08);
}
.login-card input::placeholder { color: var(--muted); }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 0.92rem; font-weight: 600;
  padding: 12px 18px; border-radius: var(--r-sm);
  border: 1px solid transparent; cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--gradient-gold); color: #14213d; box-shadow: var(--glow-gold); }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(255, 176, 32, 0.45); }
.btn-ghost { background: var(--surface); color: var(--text-soft); border-color: var(--border); }
.btn-ghost:hover { border-color: var(--border-gold); color: var(--text); background: var(--surface-hover); }

/* ── App shell ────────────────────────────────────────────── */
.app { max-width: 1400px; margin: 0 auto; padding: 22px 22px 80px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  background: var(--card);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 14px 20px; margin-bottom: 22px; box-shadow: var(--shadow);
}
.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }
.brand-logo { height: 40px; width: auto; object-fit: contain; }
.brand-divider { width: 1px; height: 34px; background: var(--border-2); flex: none; }
.brand-text strong { display: block; font-size: 1.08rem; font-weight: 600; letter-spacing: -0.01em; }
.brand-text .brand-sub { color: var(--muted); font-size: 0.78rem; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.pill-live {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.76rem; font-weight: 600; color: var(--st-termin);
  background: rgba(52, 211, 153, 0.12); border: 1px solid rgba(52, 211, 153, 0.28);
  padding: 6px 12px; border-radius: 999px;
}
.pill-live .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--st-termin); box-shadow: 0 0 0 0 rgba(52,211,153,0.6); animation: pulse 2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(52,211,153,0.5); } 70% { box-shadow: 0 0 0 7px rgba(52,211,153,0); } 100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); } }

/* ── KPI cards ────────────────────────────────────────────── */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 16px; margin-bottom: 22px;
}
.kpi {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 15px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--r-lg); padding: 18px 20px;
  cursor: pointer; text-align: left;
  transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1), border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}
.kpi::after {
  content: ''; position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 0 0 1.5px transparent; transition: box-shadow 0.25s ease; pointer-events: none;
}
.kpi:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-2); }
.kpi.active { background: rgba(255, 215, 0, 0.07); }
.kpi.active::after { box-shadow: inset 0 0 0 1.5px var(--border-gold); }
.kpi-icon {
  width: 46px; height: 46px; border-radius: 14px; flex: none;
  display: grid; place-items: center; font-size: 1.35rem;
  background: rgba(255, 255, 255, 0.05);
}
.kpi-body { min-width: 0; display: flex; flex-direction: column; }
.kpi .num { display: block; font-size: 1.85rem; font-weight: 600; letter-spacing: -0.03em; line-height: 1.05; }
.kpi .label { color: var(--muted); font-size: 0.82rem; margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Toolbar / filters ────────────────────────────────────── */
.toolbar {
  display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 14px;
}
.search-wrap { position: relative; flex: 1; min-width: 240px; }
.search-wrap .search-ico {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 1.05rem; pointer-events: none;
}
.search-wrap input {
  width: 100%; padding: 12px 14px 12px 42px; border-radius: var(--r-sm);
  font-family: inherit; font-size: 0.92rem;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.select {
  position: relative;
}
.select select {
  appearance: none; -webkit-appearance: none;
  padding: 12px 38px 12px 14px; border-radius: var(--r-sm);
  font-family: inherit; font-size: 0.92rem; cursor: pointer;
  background: var(--card); color: var(--text); border: 1px solid var(--border);
  transition: all 0.2s ease;
}
.select::after {
  content: ''; position: absolute; right: 15px; top: 50%; width: 8px; height: 8px;
  border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg); pointer-events: none;
}
.search-wrap input:focus, .select select:focus {
  outline: none; border-color: var(--gold);
  box-shadow: 0 0 0 4px rgba(255, 215, 0, 0.12); background: rgba(255, 255, 255, 0.06);
}
.search-wrap input::placeholder { color: var(--muted); }
.result-meta { color: var(--muted); font-size: 0.85rem; margin: 0 2px 14px; }
.result-meta b { color: var(--text); font-weight: 600; }

/* ── Table ────────────────────────────────────────────────── */
.table-wrap {
  background: var(--card);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  overflow: hidden; box-shadow: var(--shadow);
}
table { width: 100%; border-collapse: collapse; }
thead th {
  text-align: left; padding: 15px 20px; font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 600;
  border-bottom: 1px solid var(--border); background: rgba(255, 255, 255, 0.02);
}
thead th.col-chevron { width: 44px; }
tbody td { padding: 13px 20px; border-bottom: 1px solid rgba(255, 255, 255, 0.05); font-size: 0.92rem; vertical-align: middle; }
tbody tr { cursor: pointer; transition: background 0.14s ease; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }

.company-cell { display: flex; align-items: center; gap: 13px; }
.avatar {
  width: 40px; height: 40px; border-radius: 12px; flex: none;
  display: grid; place-items: center; font-weight: 600; font-size: 0.92rem; color: #14213d;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12);
}
.company-meta { min-width: 0; }
.company-meta strong { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 320px; }
.company-meta small { color: var(--muted); font-size: 0.8rem; }
.loc-city { font-weight: 500; }
.loc-zip { color: var(--muted); font-size: 0.8rem; }

.contact-icons { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.contact-icons .has { color: var(--gold); }
.phone-text { font-variant-numeric: tabular-nums; }

.chev { color: var(--muted); display: grid; place-items: center; }
tbody tr:hover .chev { color: var(--gold); }

.badge {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.badge .bdot { width: 7px; height: 7px; border-radius: 50%; }
.badge[data-status="Neu"] { background: rgba(56,189,248,0.12); color: #7dd3fc; border-color: rgba(56,189,248,0.3); }
.badge[data-status="Neu"] .bdot { background: var(--st-neu); }
.badge[data-status="Angerufen"] { background: rgba(251,191,36,0.12); color: #fcd34d; border-color: rgba(251,191,36,0.3); }
.badge[data-status="Angerufen"] .bdot { background: var(--st-angerufen); }
.badge[data-status="Kein Interesse"] { background: rgba(251,113,133,0.12); color: #fda4af; border-color: rgba(251,113,133,0.3); }
.badge[data-status="Kein Interesse"] .bdot { background: var(--st-kein); }
.badge[data-status="Qualifizierter Lead"] { background: rgba(167,139,250,0.14); color: #c4b5fd; border-color: rgba(167,139,250,0.3); }
.badge[data-status="Qualifizierter Lead"] .bdot { background: var(--st-qual); }
.badge[data-status="Termin vereinbart"] { background: rgba(52,211,153,0.16); color: #6ee7b7; border-color: rgba(52,211,153,0.36); }
.badge[data-status="Termin vereinbart"] .bdot { background: var(--st-termin); }

/* Empty & skeleton */
.empty { padding: 64px 20px; text-align: center; color: var(--muted); }
.empty .empty-ico { font-size: 2.6rem; opacity: 0.5; margin-bottom: 12px; }
.empty h3 { color: var(--text-soft); font-weight: 600; margin-bottom: 4px; }
.skel-row td { padding: 16px 20px; }
.skel { height: 16px; border-radius: 6px; background: linear-gradient(90deg, rgba(255,255,255,0.05) 25%, rgba(255,255,255,0.1) 37%, rgba(255,255,255,0.05) 63%); background-size: 400% 100%; animation: shimmer 1.4s infinite; }
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

/* ── Detail drawer ────────────────────────────────────────── */
.detail-overlay { position: fixed; inset: 0; z-index: 90; }
.detail-backdrop { position: absolute; inset: 0; background: rgba(3, 8, 18, 0.6); backdrop-filter: blur(3px); animation: fade 0.2s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.detail-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: 520px; max-width: 94vw;
  background: #0e1a2b; border-left: 1px solid var(--border-gold);
  box-shadow: var(--shadow-lg); overflow-y: auto; padding: 26px 28px 44px;
  animation: slideIn 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
}
@keyframes slideIn { from { transform: translateX(48px); opacity: 0; } to { transform: none; opacity: 1; } }

.detail-head { display: flex; align-items: flex-start; gap: 14px; padding-right: 34px; }
.detail-head .avatar { width: 52px; height: 52px; border-radius: 15px; font-size: 1.15rem; }
.detail-head h2 { font-size: 1.32rem; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; }
.detail-head .sub { color: var(--muted); font-size: 0.86rem; margin-top: 2px; }
.detail-close {
  position: absolute; top: 22px; right: 22px; width: 34px; height: 34px;
  display: grid; place-items: center; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted);
  font-size: 1.1rem; cursor: pointer; transition: all 0.2s ease;
}
.detail-close:hover { color: var(--text); border-color: var(--border-gold); }

/* Quick actions */
.quick-actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 20px; }
.qa {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  padding: 13px 8px; border-radius: var(--r-sm); text-decoration: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
  font-size: 0.74rem; font-weight: 500; transition: all 0.2s ease;
}
.qa .qa-ico { font-size: 1.2rem; display: grid; place-items: center; }
.qa:hover { transform: translateY(-2px); border-color: var(--border-gold); color: var(--text); background: var(--surface-hover); }
.qa.primary { background: var(--gradient-gold); color: #14213d; border-color: transparent; box-shadow: var(--glow-gold); }
.qa.primary:hover { color: #14213d; }
.qa.disabled { opacity: 0.4; pointer-events: none; }

.detail-section { margin-top: 26px; }
.detail-section > h3 {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin-bottom: 13px; font-weight: 600;
}

.info-list { display: flex; flex-direction: column; gap: 1px; border-radius: var(--r-sm); overflow: hidden; border: 1px solid var(--border); }
.info-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--surface); }
.info-row .ir-ico { color: var(--muted); font-size: 1.05rem; display: grid; place-items: center; flex: none; }
.info-row .ir-k { color: var(--muted); font-size: 0.78rem; flex: none; width: 84px; }
.info-row .ir-v { font-size: 0.9rem; flex: 1; min-width: 0; word-break: break-word; }
.link-out { color: var(--gold); text-decoration: none; font-weight: 500; }
.link-out:hover { text-decoration: underline; }

/* Status chips */
.status-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px;
  font-size: 0.82rem; font-weight: 600; cursor: pointer; user-select: none;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-soft);
  transition: all 0.18s ease;
}
.chip .cdot { width: 8px; height: 8px; border-radius: 50%; }
.chip:hover { border-color: var(--border-2); }
.chip.selected { color: var(--text); }
.chip[data-status="Neu"].selected { background: rgba(56,189,248,0.16); border-color: var(--st-neu); }
.chip[data-status="Angerufen"].selected { background: rgba(251,191,36,0.16); border-color: var(--st-angerufen); }
.chip[data-status="Kein Interesse"].selected { background: rgba(251,113,133,0.16); border-color: var(--st-kein); }
.chip[data-status="Qualifizierter Lead"].selected { background: rgba(167,139,250,0.18); border-color: var(--st-qual); }
.chip[data-status="Termin vereinbart"].selected { background: rgba(52,211,153,0.18); border-color: var(--st-termin); }

.field { margin-top: 14px; }
.field label { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 7px; }
.field textarea {
  width: 100%; min-height: 118px; resize: vertical; font-family: inherit; font-size: 0.92rem;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 14px; transition: all 0.2s ease; line-height: 1.5;
}
.field textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px rgba(255,215,0,0.12); background: rgba(255,255,255,0.05); }
.field textarea::placeholder { color: var(--muted); }

.save-btn { width: 100%; margin-top: 16px; padding: 14px; font-size: 0.95rem; }

/* Timeline */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ''; position: absolute; left: 5px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 16px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before { content: ''; position: absolute; left: -21px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 3px rgba(255,215,0,0.15); }
.tl-item .tl-outcome { font-weight: 600; font-size: 0.86rem; }
.tl-item .tl-note { color: var(--text-soft); font-size: 0.82rem; }
.tl-item .tl-time { color: var(--muted); font-size: 0.74rem; margin-top: 2px; }
.empty-inline { color: var(--muted); font-size: 0.88rem; padding: 4px 0; }

/* ── Toast ────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%) translateY(0);
  display: inline-flex; align-items: center; gap: 9px;
  background: #14213d; color: var(--text); border: 1px solid var(--border-gold);
  padding: 13px 22px; border-radius: 999px; font-weight: 600; font-size: 0.9rem;
  box-shadow: var(--shadow-lg); z-index: 200; animation: toastIn 0.25s ease;
}
.toast.ok { border-color: rgba(52,211,153,0.5); }
.toast.ok .t-ico { color: var(--st-termin); }
.toast.err { border-color: rgba(251,113,133,0.5); }
.toast.err .t-ico { color: var(--st-kein); }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(12px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.13); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 215, 0, 0.35); }

/* Responsive */
@media (max-width: 720px) {
  .app { padding: 16px 14px 60px; }
  thead th.col-legal, tbody td.col-legal,
  thead th.col-contact, tbody td.col-contact { display: none; }
  .brand-sub { display: none; }
  .company-meta strong { max-width: 46vw; }
}
