/* TPC Lead Tracker — matches landing page design tokens */
:root {
  --bg: #0a0a0a;
  --bg-raised: #111111;
  --bg-card: #161616;
  --fg: #e8e8e8;
  --fg-muted: #888888;
  --accent: #f97316;
  --accent-glow: rgba(249, 115, 22, 0.15);
  --accent-2: #fb923c;
  --border: #222222;
  --border-light: #2a2a2a;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 220px;
}

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  display: flex;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; font-weight: 700; }

/* ── SIDEBAR ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-icon { font-size: 24px; }
.brand-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; color: var(--fg); line-height: 1.2; }
.brand-sub { font-size: 11px; color: var(--accent); letter-spacing: 1px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-radius: 0;
  transition: color 0.15s, background 0.15s;
  position: relative;
}
.nav-item:hover { color: var(--fg); background: rgba(249,115,22,0.06); }
.nav-item.active { color: var(--accent); background: rgba(249,115,22,0.1); }
.nav-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-icon { font-size: 15px; }
.badge-count {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer { padding: 16px; }
.btn-add-lead {
  width: 100%;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn-add-lead:hover { background: var(--accent-2); transform: translateY(-1px); }
.btn-add-lead span { font-size: 18px; line-height: 1; }

/* ── MAIN ── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  overflow-x: auto;
}

/* ── TOPBAR ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar-left { display: flex; align-items: baseline; gap: 10px; }
.page-title { font-size: 20px; color: var(--fg); }
.lead-count { font-size: 12px; color: var(--fg-muted); }

.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-select {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  color: var(--fg-muted);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12px;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.filter-select:hover, .filter-select:focus { border-color: var(--accent); color: var(--fg); }
.filter-clear {
  color: var(--fg-muted);
  text-decoration: none;
  font-size: 12px;
  padding: 7px 10px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  transition: color 0.15s;
}
.filter-clear:hover { color: var(--accent); border-color: var(--accent); }

/* ── METRICS ── */
.metrics-strip {
  display: flex;
  gap: 12px;
  padding: 16px 28px;
  overflow-x: auto;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  min-width: 130px;
  flex-shrink: 0;
  transition: border-color 0.2s;
}
.metric-card:hover { border-color: var(--border-light); }
.metric-card.hot { border-color: rgba(249,115,22,0.3); }
.metric-card.won { border-color: rgba(34,197,94,0.3); }
.metric-card.overdue { border-color: rgba(239,68,68,0.3); }
.metric-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 26px;
  font-weight: 700;
  color: var(--fg);
  line-height: 1;
}
.metric-card.hot .metric-value { color: var(--accent); }
.metric-card.won .metric-value { color: #22c55e; }
.metric-card.overdue .metric-value { color: #ef4444; }
.metric-label { font-size: 11px; color: var(--fg-muted); margin-top: 4px; letter-spacing: 0.3px; }

/* ── KANBAN ── */
.kanban-board {
  display: flex;
  gap: 0;
  flex: 1;
  overflow-x: auto;
  padding: 20px 28px;
  align-items: flex-start;
  gap: 12px;
}

.kanban-col {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  min-width: 240px;
  max-width: 260px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
}

.kanban-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.stage-label {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 4px;
}
.stage-cold    { background: rgba(100,100,120,0.2); color: #9999bb; }
.stage-warm    { background: rgba(251,191,36,0.15); color: #fbbf24; }
.stage-hot     { background: rgba(249,115,22,0.2); color: var(--accent); }
.stage-negotiation { background: rgba(139,92,246,0.2); color: #a78bfa; }
.stage-won     { background: rgba(34,197,94,0.2); color: #22c55e; }
.stage-lost    { background: rgba(239,68,68,0.15); color: #ef4444; }

.col-count {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted);
  background: var(--bg-card);
  padding: 2px 7px;
  border-radius: 10px;
}

.kanban-cards {
  overflow-y: auto;
  flex: 1;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.add-in-col {
  background: transparent;
  border: none;
  border-top: 1px solid var(--border);
  color: var(--fg-muted);
  padding: 10px;
  font-size: 12px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  border-radius: 0 0 var(--radius) var(--radius);
}
.add-in-col:hover { color: var(--accent); background: rgba(249,115,22,0.05); }

/* ── LEAD CARD ── */
.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.lead-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(249,115,22,0.1);
}
.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 6px; margin-bottom: 6px; }
.card-company { font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 13px; color: var(--fg); line-height: 1.3; }
.card-seg-badge {
  font-size: 10px;
  color: var(--fg-muted);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}
.card-contact { font-size: 11px; color: var(--fg-muted); margin-bottom: 3px; }
.card-phone { font-size: 11px; color: var(--fg-muted); margin-bottom: 3px; }
.card-product { font-size: 11px; color: var(--accent); margin-bottom: 6px; }
.card-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: wrap; margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
.card-budget { font-family: 'Space Grotesk', sans-serif; font-size: 11px; font-weight: 600; color: #22c55e; }
.card-followup { font-size: 10px; color: var(--fg-muted); }
.card-followup.overdue { color: #ef4444; }
.card-followup.today { color: #fbbf24; }
.card-source-badge { font-size: 10px; color: var(--fg-muted); margin-left: auto; }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.modal-sm { max-width: 380px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg-raised);
  z-index: 1;
}
.modal-title { font-size: 18px; color: var(--fg); }
.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 18px;
  cursor: pointer;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--bg-card); color: var(--fg); }

/* ── FORM ── */
.lead-form { padding: 20px 24px 24px; }
.form-section-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin: 16px 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.form-section-title:first-child { margin-top: 0; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 0; }
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.form-group.required label::after { content: ' *'; color: var(--accent); }
.form-group label { font-size: 12px; font-weight: 500; color: var(--fg-muted); }
.form-group input, .form-group select, .form-group textarea {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--fg);
  padding: 9px 12px;
  font-size: 13px;
  font-family: 'DM Sans', sans-serif;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(249,115,22,0.1);
}
.form-group textarea { resize: vertical; min-height: 72px; }
.form-group select { cursor: pointer; }

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-2); }
.btn-secondary {
  background: var(--bg-card);
  color: var(--fg-muted);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.btn-secondary:hover { color: var(--fg); border-color: var(--border); }
.btn-danger {
  background: #ef4444;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 22px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-danger:hover { background: #dc2626; }

.delete-msg { padding: 16px 24px; color: var(--fg-muted); font-size: 13px; }

/* ── DRAWER ── */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 150;
  display: none;
  backdrop-filter: blur(2px);
}
.drawer-overlay.open { display: block; }

.drawer {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: 420px;
  background: var(--bg-raised);
  border-left: 1px solid var(--border-light);
  z-index: 160;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -10px 0 40px rgba(0,0,0,0.4);
}
.drawer-overlay.open .drawer { transform: translateX(0); }

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}
.drawer-title { font-size: 16px; color: var(--fg); }
.drawer-actions { display: flex; gap: 6px; align-items: center; }
.btn-icon {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.15s;
}
.btn-icon:hover { border-color: var(--accent); }
.btn-danger-icon:hover { border-color: #ef4444; }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.detail-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  width: 130px;
  flex-shrink: 0;
}
.detail-value { font-size: 13px; color: var(--fg); flex: 1; word-break: break-word; }

/* Stage selector in drawer */
.stage-selector { display: flex; gap: 6px; flex-wrap: wrap; }
.stage-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-muted);
  padding: 5px 10px;
  font-size: 11px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: all 0.15s;
}
.stage-btn:hover { border-color: var(--accent); color: var(--accent); }
.stage-btn.active { background: var(--accent); color: #000; border-color: var(--accent); }
.stage-btn.active-won { background: #22c55e; color: #000; border-color: #22c55e; }
.stage-btn.active-lost { background: #ef4444; color: #fff; border-color: #ef4444; }

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 13px;
  color: var(--fg);
  z-index: 300;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { border-left: 3px solid #22c55e; }
.toast.error { border-left: 3px solid #ef4444; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--fg-muted); }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { width: 100%; height: auto; position: relative; flex-direction: row; flex-wrap: wrap; }
  .main { margin-left: 0; }
  .kanban-board { padding: 12px; }
  .drawer { width: 100%; }
  .form-row { grid-template-columns: 1fr; }
}
