/* ══════════════════════════════════════════
   Kineiro Dashboard — стили
══════════════════════════════════════════ */

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

:root {
  --bg:      #f1f5f9;
  --surface: #ffffff;
  --border:  #e2e8f0;
  --text:    #1e293b;
  --muted:   #64748b;
  --primary: #2563eb;
  --primary-light: #eff6ff;

  --status-new:       #64748b;
  --status-contacted: #2563eb;
  --status-replied:   #d97706;
  --status-meeting:   #16a34a;

  --niche-clinic:    #e11d48;
  --niche-fitness:   #7c3aed;
  --niche-beauty:    #db2777;
  --niche-restaurant:#ea580c;
  --niche-hotel:     #0891b2;
  --niche-realestate:#059669;
  --niche-psychology:#6d28d9;
  --niche-kids:      #d97706;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ── Navbar ───────────────────────────────── */

.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: -.3px;
  min-width: 160px;
}
.nav-logo { font-size: 20px; }


.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.collect-status {
  font-size: 12px;
  color: var(--muted);
}
.collect-status.running { color: var(--primary); }

.nav-user {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  padding: 0 4px;
}

/* ── Buttons ──────────────────────────────── */

.btn {
  padding: 7px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: all .15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-primary:disabled { opacity: .5; cursor: default; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-ghost { background: none; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }

/* ── Toolbar ──────────────────────────────── */

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.filters { display: flex; gap: 8px; }
.filter-select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.toolbar-stats { font-size: 13px; color: var(--muted); }

/* ── Leads list ───────────────────────────── */

.leads-list {
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lead-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 20px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  transition: box-shadow .15s;
}
.lead-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,.08); }

.lead-main { min-width: 0; }

.lead-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.lead-company {
  font-weight: 600;
  font-size: 15px;
}
.lead-niche {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg);
  color: var(--muted);
  white-space: nowrap;
}
.lead-score {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

.lead-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 13px;
  color: var(--muted);
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.lead-meta a { color: var(--primary); text-decoration: none; }
.lead-meta a:hover { text-decoration: underline; }
.lead-contact { display: flex; align-items: center; gap: 4px; }
.lead-contact.has-wa { color: #16a34a; font-weight: 500; }

.lead-comment-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.lead-comment-input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 36px;
  background: var(--bg);
  transition: border-color .15s;
}
.lead-comment-input:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
}

.lead-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  min-width: 140px;
}

.status-select {
  width: 100%;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 2px solid;
  cursor: pointer;
  appearance: none;
  text-align: center;
}
.status-new       { border-color: var(--status-new);       color: var(--status-new);       background: #f8fafc; }
.status-contacted { border-color: var(--status-contacted); color: var(--status-contacted); background: #eff6ff; }
.status-replied   { border-color: var(--status-replied);   color: var(--status-replied);   background: #fffbeb; }
.status-meeting   { border-color: var(--status-meeting);   color: var(--status-meeting);   background: #f0fdf4; }

.lead-date { font-size: 11px; color: var(--muted); }

/* Бейдж «протух» */
.badge-stale {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 20px;
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
  white-space: nowrap;
}

/* Карточка протухшего лида — лёгкий фон */
.lead-card.is-stale {
  border-color: #fed7aa;
  background: #fffbf7;
}

.contacted-at {
  font-size: 11px;
  color: var(--muted);
}

.btn-script {
  width: 100%;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  text-align: center;
  transition: all .15s;
}
.btn-script:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); }

/* ── Empty state ──────────────────────────── */

.empty-state {
  text-align: center;
  padding: 80px 24px;
  color: var(--muted);
}
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-sub  { font-size: 13px; margin-top: 4px; }
.hidden { display: none !important; }

/* ── Stats row ───────────────────────────── */

.stats-row {
  display: flex;
  gap: 12px;
  padding: 16px 24px;
  flex-wrap: wrap;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.stat-card {
  flex: 1;
  min-width: 100px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 16px;
  text-align: center;
}
.stat-value { font-size: 24px; font-weight: 700; line-height: 1; margin-bottom: 4px; }
.stat-label { font-size: 12px; color: var(--muted); }

/* ── Funnel section ──────────────────────── */

.funnel-section {
  padding: 24px;
}

.funnel-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .funnel-grid { grid-template-columns: 1fr; }
}

.funnel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  color: var(--text);
}

.funnel-steps { display: flex; flex-direction: column; gap: 8px; }

.funnel-step {
  display: grid;
  grid-template-columns: 100px 1fr 40px;
  align-items: center;
  gap: 12px;
}
.funnel-step-label { font-size: 13px; color: var(--muted); }
.funnel-step-bar-wrap {
  background: var(--bg);
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
}
.funnel-step-bar {
  height: 100%;
  border-radius: 20px;
  transition: width .5s ease;
}
.funnel-step-count { font-size: 13px; font-weight: 600; text-align: right; }

.step-new       .funnel-step-bar { background: var(--status-new); }
.step-contacted .funnel-step-bar { background: var(--status-contacted); }
.step-replied   .funnel-step-bar { background: var(--status-replied); }
.step-meeting   .funnel-step-bar { background: var(--status-meeting); }

.funnel-conversion {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.conv-stale { color: #c2410c; }
.conv-ok    { color: #16a34a; }

/* ── Niche bars ──────────────────────────── */

.niche-bars { display: flex; flex-direction: column; gap: 10px; }

.niche-bar-row {
  display: grid;
  grid-template-columns: 140px 1fr 36px;
  align-items: center;
  gap: 10px;
}
.niche-bar-label { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.niche-bar-wrap {
  background: var(--bg);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
}
.niche-bar-fill {
  height: 100%;
  border-radius: 20px;
  background: var(--primary);
  transition: width .5s ease;
}
.niche-bar-count { font-size: 12px; font-weight: 600; text-align: right; color: var(--text); }

/* ── Modal ────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 24px;
}
.modal {
  background: var(--surface);
  border-radius: 16px;
  max-width: 560px;
  width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
}
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
  line-height: 1;
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  color: var(--text);
}

/* ── Loader ───────────────────────────────── */
.loader { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
