/* ────────────────────────────────────────────────────────────────────────
   LEAD MANAGER — Styles
   Dark, ruhig, an mango-dashboard angelehnt.
   ──────────────────────────────────────────────────────────────────────── */

:root {
  --bg:         #0a0a0b;
  --bg-elev:    #111114;
  --surface:    #15151a;
  --surface-2:  #1c1c22;
  --border:     rgba(255, 255, 255, 0.06);
  --border-2:   rgba(255, 255, 255, 0.10);
  --text:       #e4e4e7;
  --text-dim:   #a1a1aa;
  --text-faint: #71717a;
  --accent:     #f59e0b;
  --accent-2:   #fbbf24;
  --danger:     #ef4444;
  --success:    #10b981;
  --info:       #3b82f6;
  --radius:     12px;
  --radius-lg:  16px;
  --shadow:     0 4px 24px -4px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.03) inset;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Geist Sans', 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }

/* ─── Layout ──────────────────────────────────────────────────────────── */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
.container {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px;
}
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.page-head h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.page-sub {
  color: var(--text-dim);
  margin: 4px 0 0;
}

/* ─── Nav ─────────────────────────────────────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: rgba(10, 10, 11, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
  margin-right: 8px;
}
.brand-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 12px rgba(245,158,11,0.4);
}
.nav-items {
  display: flex;
  gap: 4px;
  flex: 1;
}
.nav-item {
  padding: 7px 12px;
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  transition: all 120ms;
}
.nav-item:hover { color: var(--text); background: var(--surface); }
.nav-item.active { color: var(--text); background: var(--surface-2); }

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn-primary, .btn-ghost, .btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  transition: all 120ms;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0a0b;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(245,158,11,0.3); }
.btn-ghost {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--surface-2); border-color: var(--border-2); }
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.1); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.card-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

/* ─── Stat grid (Dashboard) ───────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all 150ms;
  position: relative;
  overflow: hidden;
}
.stat:hover { background: var(--surface-2); transform: translateY(-1px); }
.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.stat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.stat-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 4px;
}

/* Two-column dashboard */
.dash-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 20px;
}
@media (max-width: 1000px) {
  .dash-grid { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
}

/* ─── Tables ──────────────────────────────────────────────────────────── */
table.leads-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 13px;
}
.leads-table th {
  text-align: left;
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  position: sticky;
  top: 56px;
  z-index: 5;
}
.leads-table td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.leads-table tbody tr {
  cursor: pointer;
  transition: background 100ms;
}
.leads-table tbody tr:hover { background: var(--surface-2); }
.lead-name { font-weight: 500; color: var(--text); }
.lead-sub { color: var(--text-faint); font-size: 12px; margin-top: 2px; }

/* ─── Status Pill ─────────────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid currentColor;
  background: color-mix(in srgb, currentColor 8%, transparent);
}
.pill-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── Avatar ──────────────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #27272a, #18181b);
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border);
  flex-shrink: 0;
}
.avatar-lg { width: 56px; height: 56px; font-size: 16px; }

/* ─── Inputs ──────────────────────────────────────────────────────────── */
input[type="text"], input[type="email"], input[type="tel"], input[type="url"],
input[type="date"], input[type="datetime-local"], input:not([type]),
select, textarea {
  width: 100%;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 120ms, background 120ms;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}
textarea { resize: vertical; min-height: 80px; }
label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 14px;
}
label input, label select, label textarea {
  margin-top: 4px;
}

/* ─── Filter bar ──────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar input[type="search"], .filter-bar input[type="text"] {
  max-width: 340px;
}
.filter-bar select { max-width: 200px; }
.filter-chip {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12px;
  cursor: pointer;
  transition: all 120ms;
}
.filter-chip:hover { color: var(--text); border-color: var(--border-2); }
.filter-chip.active {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-2);
}

/* ─── Pipeline Kanban ─────────────────────────────────────────────────── */
.kanban {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding-bottom: 16px;
}
.kanban-col {
  min-width: 270px;
  flex: 1 1 270px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 160px);
}
.kanban-col.drop-target {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 4%, var(--bg-elev));
}
.kanban-col-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.kanban-col-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
}
.kanban-count {
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface);
  padding: 2px 8px;
  border-radius: 999px;
}
.kanban-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.kanban-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  cursor: grab;
  transition: all 120ms;
}
.kanban-card:hover { background: var(--surface-2); transform: translateY(-1px); border-color: var(--border-2); }
.kanban-card.dragging { opacity: 0.4; }
.kanban-card-name { font-weight: 500; font-size: 13px; }
.kanban-card-meta { color: var(--text-faint); font-size: 11px; margin-top: 4px; }

/* ─── Detail page ─────────────────────────────────────────────────────── */
.detail-grid {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .detail-grid { grid-template-columns: 1fr; }
}
.profile-card .header {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 16px;
}
.profile-card .meta {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.kv {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  font-size: 13px;
  align-items: start;
}
.kv > .k { color: var(--text-faint); font-size: 12px; }
.kv input, .kv select, .kv textarea { font-size: 13px; }

.tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 8px 14px;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all 120ms;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Conversation Timeline ──────────────────────────────────────────── */
.timeline {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.bubble-wrap { display: flex; gap: 10px; }
.bubble-wrap.outbound { flex-direction: row-reverse; }
.bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
}
.bubble.inbound { background: var(--surface-2); border-bottom-left-radius: 4px; }
.bubble.outbound { background: rgba(245, 158, 11, 0.15); border: 1px solid rgba(245,158,11,0.2); border-bottom-right-radius: 4px; }
.bubble-meta {
  font-size: 11px;
  color: var(--text-faint);
  margin-top: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.bubble-channel {
  background: var(--surface);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}
.compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.compose-row {
  display: flex;
  gap: 8px;
}
.compose-row select { flex: 0 0 140px; }
.compose textarea { min-height: 70px; }

/* ── Activity list ──────────────────────────────────────────────────── */
.activity-list { display: flex; flex-direction: column; gap: 10px; }
.activity-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  align-items: flex-start;
}
.activity-item:last-child { border-bottom: none; }
.activity-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  color: var(--text-dim);
  flex-shrink: 0;
}
.activity-body { flex: 1; font-size: 13px; }
.activity-meta { color: var(--text-faint); font-size: 11px; margin-top: 2px; }

/* ─── Modal ───────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  animation: fade-in 120ms;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 540px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { margin: 0; font-size: 16px; font-weight: 600; }
.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  width: 28px; height: 28px;
  border-radius: 6px;
}
.modal-close:hover { color: var(--text); background: var(--surface); }
.modal-body { padding: 20px; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ─── Toast ───────────────────────────────────────────────────────────── */
#toast-host {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 100;
}
.toast {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  animation: slide-in 180ms ease;
}
.toast-error { border-color: var(--danger); color: var(--danger); }
.toast-out { animation: slide-out 200ms ease forwards; }

/* ─── Login ───────────────────────────────────────────────────────────── */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top, rgba(245, 158, 11, 0.08), transparent 50%),
    radial-gradient(ellipse at bottom, rgba(59, 130, 246, 0.05), transparent 50%);
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 24px;
}
.login-card h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.login-card .page-sub {
  margin: 6px 0 24px;
}
.login-card label {
  margin-bottom: 16px;
}
.login-error {
  margin-top: 14px;
  padding: 10px 12px;
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #fca5a5;
  border-radius: 8px;
  font-size: 12px;
}

/* ─── User-Menu in Nav ────────────────────────────────────────────────── */
.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.nav-user button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  padding: 0 0 0 4px;
  font-size: 11px;
  border-left: 1px solid var(--border-2);
  margin-left: 4px;
  cursor: pointer;
}
.nav-user button:hover { color: var(--danger); }

/* ─── States ──────────────────────────────────────────────────────────── */
.empty {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-faint);
}
.empty h3 { color: var(--text-dim); font-weight: 500; margin: 0 0 6px; }
.loading {
  padding: 40px;
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
}

/* ─── Animations ──────────────────────────────────────────────────────── */
@keyframes fade-in  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slide-in { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slide-out { to { transform: translateX(20px); opacity: 0; } }

/* ─── Scrollbars ──────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }
