:root {
  --bg: #0b0d10; --surface: #13161c; --surface-2: #1a1f28;
  --border: #232a36; --text: #e8edf5; --text-2: #8b95a8;
  --accent: #6c8cff; --accent-glow: rgba(108,140,255,0.08);
  --green: #34d399; --green-bg: rgba(52,211,153,0.1);
  --amber: #fbbf24; --amber-bg: rgba(251,191,36,0.1);
  --red: #f87171; --red-bg: rgba(248,113,113,0.1);
  --radius: 12px; --radius-sm: 8px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg); color: var(--text);
  line-height: 1.5; padding: 20px; min-height: 100vh;
}
.container { max-width: 1400px; margin: 0 auto; }

/* Nav */
.nav {
  display: flex; gap: 4px; margin-bottom: 24px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 4px; overflow-x: auto;
}
.nav-btn {
  padding: 10px 20px; border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-2); font-size: 14px;
  font-weight: 500; cursor: pointer; transition: all 0.15s;
  white-space: nowrap; font-family: inherit;
}
.nav-btn:hover { color: var(--text); background: var(--surface-2); }
.nav-btn.active { background: var(--accent); color: #fff; }
.nav-btn .count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  border-radius: 10px; font-size: 11px; font-weight: 600;
  margin-left: 6px; background: var(--surface-2);
}
.nav-btn.active .count { background: rgba(255,255,255,0.2); color: #fff; }

.page { display: none; }
.page.active { display: block; }

/* Header row */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 20px; flex-wrap: wrap; gap: 12px;
}
.page-header h2 { font-size: 20px; font-weight: 700; }
.page-header p { color: var(--text-2); font-size: 13px; margin-top: 2px; }

/* Stats row */
.stats {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
}
.stat-card .label { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.5px; font-weight: 500; }
.stat-card .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat-card .sub { font-size: 11px; color: var(--text-2); margin-top: 2px; }

/* Lead cards */
.lead-list { display: flex; flex-direction: column; gap: 10px; }
.lead-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); transition: border-color 0.2s;
}
.lead-card:hover { border-color: var(--accent); }
.lead-card-main {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 18px; cursor: pointer;
}
.lead-card.expanded .lead-card-main { border-bottom: 1px solid var(--border); }

.lead-score {
  flex-shrink: 0; width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
}
.score-high { background: var(--green-bg); color: var(--green); }
.score-mid { background: var(--amber-bg); color: var(--amber); }
.score-low { background: var(--red-bg); color: var(--red); }

.lead-info { flex: 1; min-width: 0; }
.lead-info .name { font-size: 15px; font-weight: 600; }
.lead-info .meta { font-size: 12px; color: var(--text-2); margin-top: 2px; }

.lead-tags { display: flex; gap: 4px; flex-wrap: wrap; flex-shrink: 0; }
.lead-tag {
  padding: 3px 8px; border-radius: 5px; font-size: 11px; font-weight: 500;
  background: var(--surface-2); border: 1px solid var(--border);
}
.lead-tag.open { background: var(--green-bg); color: var(--green); border-color: rgba(52,211,153,0.2); }
.lead-tag.closed { background: var(--red-bg); color: var(--red); border-color: rgba(248,113,113,0.2); }
.lead-tag.rev { background: rgba(108,140,255,0.06); color: var(--accent); border-color: rgba(108,140,255,0.2); }

.lead-actions { display: flex; gap: 6px; flex-shrink: 0; }
.lead-actions .btn {
  padding: 6px 14px; border-radius: var(--radius-sm); font-size: 12px;
  font-weight: 500; border: none; cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.btn-approve { background: var(--green-bg); color: var(--green); border: 1px solid rgba(52,211,153,0.2); }
.btn-approve:hover { background: rgba(52,211,153,0.2); }
.btn-delete { background: var(--red-bg); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }
.btn-delete:hover { background: rgba(248,113,113,0.2); }
.btn-details { background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border); }
.btn-details:hover { color: var(--text); border-color: var(--accent); }

/* Expanded details */
.lead-details {
  display: none; padding: 16px 18px;
  grid-template-columns: 1fr 1fr 1fr; gap: 16px;
}
.lead-card.expanded .lead-details { display: grid; }
.detail-col { display: flex; flex-direction: column; gap: 6px; }
.detail-col h5 { font-size: 11px; color: var(--text-2); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 500; }
.detail-row { font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.detail-row a { color: var(--accent); text-decoration: none; }
.detail-row a:hover { text-decoration: underline; }
.detail-row .check { color: var(--green); }
.detail-row .cross { color: var(--red); }

/* Pipeline kanban */
.kanban { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.kanban-col {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; min-height: 200px;
}
.kanban-col h4 {
  font-size: 13px; font-weight: 600; margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}
.kanban-col h4 .kcount {
  font-size: 11px; color: var(--text-2); font-weight: 500;
  background: var(--surface-2); padding: 1px 8px; border-radius: 10px;
}
.kanban-item {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px;
  cursor: pointer; transition: border-color 0.15s;
}
.kanban-item:hover { border-color: var(--accent); }
.kanban-item .kname { font-size: 13px; font-weight: 500; }
.kanban-item .kmeta { font-size: 11px; color: var(--text-2); margin-top: 2px; }

/* Services page */
.service-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 12px;
}
.service-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
}
.service-card h4 { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.service-card .price { font-size: 22px; font-weight: 700; color: var(--accent); margin-bottom: 8px; }
.service-card ul { list-style: none; font-size: 12px; color: var(--text-2); display: flex; flex-direction: column; gap: 4px; }
.service-card li { padding-left: 14px; position: relative; }
.service-card li::before { content: '✓'; position: absolute; left: 0; color: var(--green); }

/* Won/Archive lists */
.won-list, .archive-list { display: flex; flex-direction: column; gap: 8px; }
.won-item, .archive-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 18px;
  display: flex; align-items: center; gap: 14px;
}
.won-item .wi-name { font-size: 14px; font-weight: 600; flex: 1; }
.won-item .wi-plan { font-size: 12px; color: var(--text-2); }
.won-item .wi-date { font-size: 11px; color: var(--text-2); }
.archive-item .ai-name { font-size: 14px; font-weight: 500; flex: 1; }
.archive-item .ai-reason { font-size: 12px; color: var(--text-2); }
.archive-item .btn-restore {
  padding: 4px 12px; border-radius: var(--radius-sm); font-size: 12px;
  font-weight: 500; border: 1px solid var(--border); cursor: pointer;
  background: var(--surface-2); color: var(--text-2); font-family: inherit;
}
.archive-item .btn-restore:hover { border-color: var(--accent); color: var(--text); }

.empty-state {
  text-align: center; padding: 40px 20px; color: var(--text-2);
}
.empty-state .icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

@media (max-width: 900px) {
  .kanban { grid-template-columns: repeat(2, 1fr); }
  .lead-details { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .kanban { grid-template-columns: 1fr; }
  .lead-card-main { flex-wrap: wrap; }
  .lead-actions { width: 100%; justify-content: flex-end; }
  .nav { flex-wrap: nowrap; }
  .nav-btn { padding: 8px 12px; font-size: 13px; }
}

/* Login */
.login-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.login-overlay.hidden { display: none; }
.login-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; text-align: center;
  max-width: 360px; width: 100%;
}
.login-icon { font-size: 48px; margin-bottom: 16px; }
.login-box h2 { margin-bottom: 8px; }
.login-input {
  width: 100%; padding: 12px 16px; font-size: 15px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  font-family: inherit; margin-bottom: 12px;
}
.login-input:focus { outline: none; border-color: var(--accent); }
.login-btn {
  width: 100%; padding: 12px; font-size: 15px; font-weight: 600;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer; font-family: inherit;
}
.login-btn:hover { opacity: 0.9; }
.login-error {
  color: var(--red); font-size: 13px; margin-top: 12px;
  display: none;
}
.login-error.show { display: block; }
