:root {
  --bg: #0f1117;
  --card: #1a1d29;
  --border: #2a2e3e;
  --text: #e4e6eb;
  --muted: #8b8fa3;
  --accent: #4f7cff;
  --accent-hover: #3a6cff;
  --green: #22c55e;
  --orange: #f59e0b;
  --red: #ef4444;
  --blue: #3b82f6;
  --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

a { color: var(--accent); text-decoration: none; }

/* Layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 220px;
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 20px 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
}
.sidebar h2 { padding: 0 20px; font-size: 18px; margin-bottom: 20px; }
.sidebar h2 span { font-size: 18px; }
.sidebar { position: fixed; bottom: 0; top: 0; overflow-y: auto; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--muted);
  cursor: pointer;
  transition: 0.15s;
}
.nav-item:hover { background: var(--border); color: var(--text); }
.nav-item.active { background: var(--border); color: var(--accent); }
.main { margin-left: 220px; padding: 24px; width: 100%; }

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; }

/* Grid */
.grid { display: grid; gap: 16px; margin-bottom: 20px; }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

/* Stats */
.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 4px; }
.stat-sub { font-size: 12px; color: var(--muted); }

/* Progress */
.progress-bar {
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 8px;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

/* Task */
.task {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  align-items: start;
  gap: 16px;
}
.task-priority {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.task-priority.p1 { background: var(--red); }
.task-priority.p2 { background: var(--orange); }
.task-priority.p3 { background: var(--blue); }
.task-priority.p4 { background: var(--accent); }
.task-priority.p5 { background: var(--muted); }
.task-content { flex: 1; }
.task-title { font-weight: 600; margin-bottom: 4px; }
.task-desc { color: var(--muted); font-size: 13px; }
.task-meta { display: flex; gap: 12px; margin-top: 8px; }
.task-meta span { font-size: 12px; color: var(--muted); }
.task-actions { display: flex; gap: 8px; }
.task-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  font-weight: 600;
}
.task-badge.auto { background: rgba(34,197,94,0.2); color: var(--green); }
.task-badge.manual { background: rgba(245,158,11,0.2); color: var(--orange); }

/* Table */
table { width: 100%; border-collapse: collapse; }
th { text-align: left; padding: 10px; border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); text-transform: uppercase; }
td { padding: 10px; border-bottom: 1px solid var(--border); }

/* Score badges */
.score-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
}
.score-badge.red { background: rgba(239,68,68,0.2); color: var(--red); }
.score-badge.orange { background: rgba(245,158,11,0.2); color: var(--orange); }
.score-badge.blue { background: rgba(59,130,246,0.2); color: var(--blue); }
.score-badge.gray { background: rgba(139,143,163,0.2); color: var(--muted); }

/* Status badges */
.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.status-badge.new { background: rgba(59,130,246,0.2); color: var(--blue); }
.status-badge.contacted { background: rgba(245,158,11,0.2); color: var(--orange); }
.status-badge.qualified { background: rgba(79,124,255,0.2); color: var(--accent); }
.status-badge.won { background: rgba(34,197,94,0.2); color: var(--green); }
.status-badge.lost { background: rgba(239,68,68,0.2); color: var(--red); }

/* Buttons */
.btn {
  padding: 8px 16px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: 0.15s;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { border-color: var(--red); color: var(--red); }

/* Inputs */
input, textarea, select {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
}
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.modal-header h3 { font-size: 18px; }

/* Tabs */
.tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 10px 20px;
  cursor: pointer;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: 0.15s;
}
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab:hover { color: var(--text); }

/* Toast */
.toast {
  position: fixed; bottom: 20px; right: 20px;
  background: var(--card);
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 12px 20px;
  z-index: 200;
  animation: slideIn 0.3s;
}
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* Config status */
.config-status { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; background: var(--bg); }
.config-dot { width: 8px; height: 8px; border-radius: 50%; }
.config-dot.ok { background: var(--green); }
.config-dot.err { background: var(--red); }
.config-dot.warn { background: var(--orange); }

/* Responsive */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .grid-4, .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
