:root {
  --c: #ED7303;
  --c2: #F39200;
  --bg: #0a0a0b;
  --surface: rgba(255,255,255,.04);
  --surface-2: rgba(255,255,255,.06);
  --border: rgba(255,255,255,.08);
  --border-strong: rgba(255,255,255,.14);
  --text: #f4f4f6;
  --muted: #9a9aa4;
  --radius: 16px;
  --shadow: 0 20px 50px -20px rgba(0,0,0,.7);
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
/* hidden-Attribut muss display-Regeln (flex/grid) schlagen */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.accent { color: var(--c2); }

/* Hintergrund-Glow (Brand) */
.bg-glow {
  position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(60% 40% at 50% -5%, color-mix(in srgb, var(--c) 22%, transparent), transparent 70%),
    radial-gradient(40% 30% at 100% 0%, color-mix(in srgb, var(--c2) 14%, transparent), transparent 60%);
}

/* ───────────────────────── Login ───────────────────────── */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100dvh; padding: 24px; }
.login-card {
  width: 100%; max-width: 380px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), rgba(255,255,255,.02));
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 38px 30px 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  animation: rise .4s cubic-bezier(.2,.7,.2,1);
}
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

.brand { text-align: center; margin-bottom: 26px; }
.brand-mark {
  width: 60px; height: 60px; margin: 0 auto 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--c), var(--c2));
  display: grid; place-items: center;
  font-size: 28px; font-weight: 800; color: #fff;
  box-shadow: 0 10px 28px -8px color-mix(in srgb, var(--c) 70%, transparent);
}
.brand-mark.sm { width: 38px; height: 38px; border-radius: 11px; font-size: 18px; margin: 0; box-shadow: none; }
.brand-logo { max-height: 60px; max-width: 200px; object-fit: contain; background: #fff; padding: 8px 12px; border-radius: 12px; margin-bottom: 14px; }
.brand h1 { font-size: 1.35rem; margin: 0; font-weight: 700; letter-spacing: -.01em; }
.brand-sub { color: var(--muted); font-size: .88rem; margin: 6px 0 0; }

form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: .78rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; padding-left: 2px; }
input {
  background: rgba(0,0,0,.25); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: 12px;
  padding: 12px 14px; font-size: 15px; width: 100%; font-family: inherit;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: #6c6c75; }
input:focus {
  outline: none; border-color: var(--c);
  background: rgba(0,0,0,.35);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--c) 22%, transparent);
}

.btn-primary {
  position: relative;
  background: linear-gradient(135deg, var(--c), var(--c2)); color: #fff;
  border: none; border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 700;
  cursor: pointer; margin-top: 4px; font-family: inherit;
  box-shadow: 0 12px 26px -10px color-mix(in srgb, var(--c) 75%, transparent);
  transition: transform .12s, filter .15s, opacity .15s;
}
.btn-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: .7; cursor: default; }
.btn-primary.is-loading .btn-label { opacity: 0; }
.btn-primary.is-loading::after {
  content: ''; position: absolute; inset: 0; margin: auto;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.form-error { color: #ff7a7a; font-size: .82rem; min-height: 1em; text-align: center; }
.form-error:empty { min-height: 0; }
.login-foot { text-align: center; color: var(--muted); font-size: .76rem; margin: 22px 0 0; }

/* ───────────────────────── Topbar ───────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; padding-top: max(14px, env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 75%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-logo { height: 34px; max-width: 130px; object-fit: contain; background: #fff; padding: 4px 7px; border-radius: 9px; }
.topbar-titles { display: flex; flex-direction: column; min-width: 0; }
.topbar-titles strong { font-size: 1rem; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-sub { font-size: .72rem; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  width: 40px; height: 40px; border-radius: 11px; cursor: pointer;
  display: grid; place-items: center; transition: background .15s, border-color .15s, transform .1s;
}
.icon-btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 19px; height: 19px; }
.icon-btn.active { color: var(--c2); border-color: color-mix(in srgb, var(--c) 50%, transparent); }

/* ───────────────────────── Content ───────────────────────── */
.content { padding: 18px; max-width: 760px; margin: 0 auto; }

.stats { display: flex; gap: 12px; margin-bottom: 18px; }
.stat {
  flex: 1; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px;
}
.stat-num { font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.stat-lbl { font-size: .78rem; color: var(--muted); }

/* Filter-Tabs */
.tabs {
  display: flex; gap: 8px; margin-bottom: 16px;
  overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); color: var(--muted);
  border: 1px solid var(--border); border-radius: 100px;
  padding: 8px 14px; font-size: .85rem; font-weight: 600; cursor: pointer;
  font-family: inherit; white-space: nowrap; transition: all .15s;
}
.tab:hover { color: var(--text); border-color: var(--border-strong); }
.tab.active { background: linear-gradient(135deg, var(--c), var(--c2)); color: #fff; border-color: transparent; }
.tab-count {
  font-size: .72rem; font-weight: 700; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 100px; display: inline-grid; place-items: center;
  background: rgba(0,0,0,.22); color: inherit;
}
.tab:not(.active) .tab-count { background: var(--surface-2); }

/* Liste */
.lead-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.list-empty { text-align: center; color: var(--muted); font-size: .9rem; padding: 40px 16px; }

.content-foot {
  text-align: center; color: var(--muted); font-size: .76rem; line-height: 1.5;
  margin: 28px auto 10px; max-width: 420px; padding: 0 10px;
}
.content-foot strong { color: var(--text); font-weight: 600; }
.lead-item {
  position: relative; overflow: hidden;
  display: flex; align-items: center; gap: 13px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .1s;
  animation: rise .3s ease both;
}
.lead-item:hover { background: var(--surface-2); border-color: var(--border-strong); }
.lead-item:active { transform: scale(.995); }
.lead-item.is-new { border-color: color-mix(in srgb, var(--c) 45%, var(--border)); }
.lead-item.is-new::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: linear-gradient(var(--c), var(--c2));
}
.lead-avatar {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--c) 85%, #000), var(--c2));
  display: grid; place-items: center; font-weight: 800; color: #fff; font-size: 1.05rem;
}
.lead-avatar.lg { width: 52px; height: 52px; border-radius: 14px; font-size: 1.3rem; }
.lead-main { flex: 1; min-width: 0; }
.lead-top { display: flex; align-items: center; gap: 8px; }
.lead-name { font-weight: 650; font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-meta { display: flex; gap: 12px; color: var(--muted); font-size: .8rem; margin-top: 4px; }
.lead-meta span { white-space: nowrap; }
.lead-side { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.lead-date { color: var(--muted); font-size: .74rem; white-space: nowrap; }
.chev { width: 18px; height: 18px; color: #55555e; }

/* Status-Badges */
.badge { font-size: .66rem; font-weight: 700; padding: 3px 9px; border-radius: 100px; letter-spacing: .03em; white-space: nowrap; }
.badge-new { background: color-mix(in srgb, var(--c) 22%, transparent); color: var(--c2); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.badge-contacted { background: rgba(80,140,255,.16); color: #9cc0ff; }
.badge-scheduled { background: rgba(160,120,255,.16); color: #c9b3ff; }
.badge-done { background: rgba(70,200,120,.16); color: #88e2a6; }
.badge-cancelled { background: rgba(255,255,255,.07); color: var(--muted); }

/* Empty / Loading */
.empty { text-align: center; padding: 70px 20px; color: var(--muted); }
.empty-icon { font-size: 3rem; margin-bottom: 14px; opacity: .9; }
.empty h2 { color: var(--text); font-size: 1.15rem; margin: 0 0 8px; font-weight: 700; }
.empty p { margin: 0 auto; max-width: 320px; font-size: .9rem; line-height: 1.55; }
.spinner {
  width: 34px; height: 34px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid var(--border-strong); border-top-color: var(--c); animation: spin .8s linear infinite;
}

/* ───────────────────────── Detail-Sheet ───────────────────────── */
.detail-overlay {
  position: fixed; inset: 0; z-index: 20;
  background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.detail-card {
  position: relative;
  background: #141417; border: 1px solid var(--border);
  border-radius: 22px 22px 0 0; width: 100%; max-width: 580px;
  max-height: 92dvh; overflow-y: auto;
  padding: 26px 22px calc(26px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow);
  animation: sheet-up .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheet-up { from { transform: translateY(28px); opacity: .5; } to { transform: none; opacity: 1; } }
.detail-close {
  position: absolute; top: 16px; right: 16px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border);
  width: 36px; height: 36px; border-radius: 11px; font-size: 20px; cursor: pointer; line-height: 1;
}
.detail-close:hover { background: var(--surface-2); }

.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.detail-head h2 { margin: 0; font-size: 1.3rem; font-weight: 750; letter-spacing: -.01em; }
.detail-time { color: var(--muted); font-size: .82rem; margin-top: 3px; }

.detail-contacts { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.contact-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--surface); border: 1px solid var(--border-strong);
  padding: 9px 14px; border-radius: 11px; font-size: .9rem; font-weight: 600;
  transition: border-color .15s, background .15s;
}
.contact-pill:hover { border-color: var(--c); background: var(--surface-2); }

.status-select { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 20px; }
.st-btn {
  background: var(--surface); color: var(--muted); border: 1px solid var(--border);
  padding: 8px 13px; border-radius: 10px; font-size: .82rem; font-weight: 600; cursor: pointer;
  transition: all .15s;
}
.st-btn:hover { border-color: var(--border-strong); color: var(--text); }
.st-btn.active { background: linear-gradient(135deg, var(--c), var(--c2)); color: #fff; border-color: transparent; }

.detail-grid { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.d-row { display: flex; gap: 14px; padding: 13px 16px; font-size: .92rem; }
.d-row + .d-row { border-top: 1px solid var(--border); }
.d-row > span:first-child { flex: 0 0 92px; color: var(--muted); font-size: .82rem; }
.d-row > div { flex: 1; word-break: break-word; }

.d-label { font-size: .78rem; color: var(--muted); font-weight: 600; margin-bottom: 9px; }
.status-select + .detail-grid { margin-top: 0; }
.status-select { margin-top: 8px; }

/* Detail-Aktionen (Löschen) */
.detail-actions { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--border); }
.btn-danger {
  width: 100%; background: rgba(255,90,90,.1); color: #ff7a7a;
  border: 1px solid rgba(255,90,90,.28); border-radius: 12px;
  padding: 12px; font-size: .92rem; font-weight: 700; cursor: pointer; font-family: inherit;
  transition: background .15s, border-color .15s;
}
.btn-danger:hover { background: rgba(255,90,90,.18); border-color: rgba(255,90,90,.5); }
.files { display: flex; flex-direction: column; gap: 9px; }
.file-link {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  padding: 13px 15px; border-radius: 12px; font-size: .9rem; cursor: pointer; font-family: inherit;
  transition: border-color .15s, background .15s;
}
.file-link:hover { border-color: var(--c); background: var(--surface-2); }
.file-size { color: var(--muted); font-size: .76rem; white-space: nowrap; }

@media (min-width: 620px) {
  .detail-overlay { align-items: center; padding: 20px; }
  .detail-card { border-radius: 22px; }
}
