/* FlipPipe Design System — Dark Theme */
:root {
  --bg-primary: #0f1117;
  --bg-secondary: #1a1d27;
  --bg-card: #1e2130;
  --bg-hover: #252838;
  --bg-input: #161822;
  --border: #2a2d3a;
  --border-light: #343748;
  --text-primary: #f0f0f5;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --accent-dim: rgba(99, 102, 241, 0.15);
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.15);
  --yellow: #eab308;
  --yellow-dim: rgba(234, 179, 8, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);
  --orange: #f97316;
  --orange-dim: rgba(249, 115, 22, 0.15);
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.4);
  --transition: all 0.2s ease;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.nav-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-primary);
  padding: 4px;
  border-radius: var(--radius);
}

.nav-tab {
  padding: 8px 20px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-tab:hover { color: var(--text-primary); background: var(--bg-hover); }
.nav-tab.active { background: var(--accent); color: white; }

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 16px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.stat-card {
  flex: 1;
  min-width: 160px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
}

.stat-value.green { color: var(--green); }
.stat-value.blue { color: var(--blue); }
.stat-value.accent { color: var(--accent); }

/* Main Content */
.main {
  padding: 24px;
}

/* Kanban Board */
.kanban-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 16px;
  min-height: calc(100vh - 200px);
}

.kanban-column {
  flex: 0 0 280px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

.column-header .count {
  background: var(--bg-hover);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-secondary);
}

.column-body {
  flex: 1;
  padding: 12px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100px;
}

.column-body.drag-over {
  background: var(--accent-dim);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* Deal Card */
.deal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: grab;
  transition: var(--transition);
  position: relative;
}

.deal-card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.deal-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.deal-card .address {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.deal-card .location {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.deal-card .deal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.deal-card .price {
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
}

.deal-card .tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 500;
}

.tag.foreclosure { background: var(--red-dim); color: var(--red); }
.tag.single_family { background: var(--blue-dim); color: var(--blue); }
.tag.multi_family { background: var(--accent-dim); color: var(--accent); }
.tag.condo { background: var(--green-dim); color: var(--green); }
.tag.townhouse { background: var(--yellow-dim); color: var(--yellow); }
.tag.land { background: var(--orange-dim); color: var(--orange); }
.tag.commercial { background: var(--accent-dim); color: var(--accent-hover); }

.deal-card .actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.deal-card .actions button {
  flex: 1;
  padding: 5px;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  transition: var(--transition);
}

.btn-analyze {
  background: var(--accent-dim);
  color: var(--accent-hover);
}
.btn-analyze:hover { background: var(--accent); color: white; }

.btn-edit {
  background: var(--bg-hover);
  color: var(--text-secondary);
}
.btn-edit:hover { background: var(--border-light); color: var(--text-primary); }

.btn-delete {
  background: var(--red-dim);
  color: var(--red);
}
.btn-delete:hover { background: var(--red); color: white; }

/* Stage colors */
.stage-lead .column-header { border-left: 3px solid var(--blue); }
.stage-analyzing .column-header { border-left: 3px solid var(--yellow); }
.stage-under_contract .column-header { border-left: 3px solid var(--orange); }
.stage-marketing .column-header { border-left: 3px solid var(--accent); }
.stage-closed .column-header { border-left: 3px solid var(--green); }

/* Buyers List */
.buyers-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.buyer-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  transition: var(--transition);
}

.buyer-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.buyer-card .buyer-name {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.buyer-card .buyer-company {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.buyer-card .buyer-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}

.buyer-card .buyer-info .label {
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.buyer-card .buyer-range {
  color: var(--green);
  font-weight: 600;
  font-size: 14px;
}

.buyer-card .buyer-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.buyer-card .buyer-actions button {
  flex: 1;
  padding: 7px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
}

/* Calculator View */
.calculator-view {
  max-width: 600px;
  margin: 0 auto;
}

.calc-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 20px;
}

.calc-card h3 {
  font-size: 16px;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.calc-result {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
}

.calc-result .mao {
  font-size: 36px;
  font-weight: 800;
  color: var(--green);
  margin-bottom: 8px;
}

.calc-result .fee {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

.calc-result .fee.positive { color: var(--green); }
.calc-result .fee.negative { color: var(--red); }

.calc-result .rating {
  display: inline-block;
  padding: 4px 16px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  margin-top: 8px;
}

.rating.excellent { background: var(--green-dim); color: var(--green); }
.rating.good { background: var(--blue-dim); color: var(--blue); }
.rating.fair { background: var(--yellow-dim); color: var(--yellow); }
.rating.poor { background: var(--red-dim); color: var(--red); }

.score-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-hover);
  border-radius: 4px;
  margin-top: 12px;
  overflow: hidden;
}

.score-bar .fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* Forms */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: white;
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-light); color: var(--text-primary); }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
}
.btn-danger:hover { background: var(--red); color: white; }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal h2 {
  font-size: 18px;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* Analysis Modal */
.analysis-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.analysis-item {
  background: var(--bg-card);
  padding: 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.analysis-item .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.analysis-item .value {
  font-size: 18px;
  font-weight: 700;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.empty-state p {
  margin-bottom: 16px;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  z-index: 2000;
  animation: slideIn 0.3s ease;
}

.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }

@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Toolbar */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.toolbar h2 {
  font-size: 18px;
}

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

/* Responsive */
@media (max-width: 768px) {
  .header { flex-direction: column; gap: 12px; padding: 12px 16px; }
  .stats-bar { padding: 12px 16px; }
  .stat-card { min-width: 130px; padding: 12px; }
  .stat-value { font-size: 20px; }
  .main { padding: 16px; }
  .kanban-column { flex: 0 0 260px; }
  .buyers-grid { grid-template-columns: 1fr; }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .analysis-grid { grid-template-columns: 1fr; }
}

/* Checkbox */
.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

/* View-specific: hidden */
.view { display: none; }
.view.active { display: block; }
