/* CRM — clean professional dashboard, dark luxury theme */
:root {
  --bg: #0e0e11;
  --surface: #18181f;
  --surface2: #1f1f28;
  --border: #2a2a35;
  --text: #f0ede8;
  --text-muted: #8a8a9a;
  --brass: #c9a96e;
  --brass-dim: rgba(201,169,110,.15);
  --success: #3ecf8e;
  --warning: #f0a500;
  --danger: #e05c5c;
  --stage-lead: #6b7280;
  --stage-scoped: #3b82f6;
  --stage-contracted: #8b5cf6;
  --stage-in-progress: #f0a500;
  --stage-completed: #3ecf8e;
}

body { background: var(--bg); color: var(--text); font-family: 'DM Sans', sans-serif; margin: 0; }

.crm-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 32px; background: var(--surface); border-bottom: 1px solid var(--border);
}
.crm-nav-logo { font-family: 'Playfair Display', serif; font-size: 20px; font-weight: 600; color: var(--brass); text-decoration: none; }
.crm-nav-links a { color: var(--text-muted); text-decoration: none; margin-left: 28px; font-size: 14px; transition: color .2s; }
.crm-nav-links a:hover, .crm-nav-links a.active { color: var(--text); }
.crm-nav-links a.active { color: var(--brass); }

.crm-container { max-width: 1400px; margin: 0 auto; padding: 32px; }

/* Stats bar */
.stats-bar {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 32px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 24px; text-align: center;
}
.stat-value { font-size: 32px; font-weight: 700; color: var(--text); margin-bottom: 4px; }
.stat-label { font-size: 13px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; }

/* Tabs */
.crm-tabs { display: flex; gap: 4px; margin-bottom: 24px; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.crm-tab {
  padding: 10px 20px; font-size: 14px; color: var(--text-muted); cursor: pointer;
  border-bottom: 2px solid transparent; background: none; border-top: none; border-left: none; border-right: none;
  transition: all .2s; text-decoration: none; display: inline-block;
}
.crm-tab:hover { color: var(--text); }
.crm-tab.active { color: var(--brass); border-bottom-color: var(--brass); }

/* Sections */
.crm-section { display: none; }
.crm-section.active { display: block; }

/* Kanban */
.kanban-board {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; align-items: start;
}
.kanban-column { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px; min-height: 400px; }
.kanban-col-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px;
}
.kanban-col-title { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); }
.kanban-col-count {
  background: var(--border); color: var(--text-muted); font-size: 12px; border-radius: 10px;
  padding: 2px 8px; font-weight: 600;
}
.kanban-col-lead .kanban-col-title { color: var(--stage-lead); }
.kanban-col-scoped .kanban-col-title { color: var(--stage-scoped); }
.kanban-col-contracted .kanban-col-title { color: var(--stage-contracted); }
.kanban-col-in_progress .kanban-col-title { color: var(--stage-in-progress); }
.kanban-col-completed .kanban-col-title { color: var(--stage-completed); }

.kanban-card {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; margin-bottom: 10px; cursor: pointer; transition: border-color .2s, transform .2s;
}
.kanban-card:hover { border-color: var(--brass); transform: translateY(-1px); }
.kanban-card-name { font-size: 14px; font-weight: 500; margin-bottom: 4px; }
.kanban-card-client { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.kanban-card-meta { font-size: 12px; color: var(--brass); }
.kanban-card-amount { font-size: 13px; font-weight: 600; color: var(--text); margin-top: 6px; }

/* Add card button */
.add-card-btn {
  width: 100%; padding: 10px; background: none; border: 1px dashed var(--border);
  border-radius: 8px; color: var(--text-muted); font-size: 13px; cursor: pointer;
  transition: all .2s; text-align: center;
}
.add-card-btn:hover { border-color: var(--brass); color: var(--brass); }

/* Clients table */
.clients-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
.clients-table { width: 100%; border-collapse: collapse; }
.clients-table th {
  text-align: left; padding: 14px 20px; font-size: 12px; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-muted); background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.clients-table td { padding: 14px 20px; font-size: 14px; border-bottom: 1px solid var(--border); color: var(--text); }
.clients-table tr:last-child td { border-bottom: none; }
.clients-table tr:hover td { background: var(--surface2); }
.clients-table .revenue { font-weight: 600; color: var(--success); }
.clients-table .project-count { color: var(--text-muted); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 16px;
  border-radius: 8px; font-size: 13px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; transition: all .2s; font-family: inherit;
}
.btn-primary { background: var(--brass); color: #0a0a0f; }
.btn-primary:hover { background: #d9ba7e; }
.btn-ghost { background: none; border-color: var(--border); color: var(--text-muted); }
.btn-ghost:hover { border-color: var(--brass); color: var(--brass); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; background: none; border: 1px solid var(--border); border-radius: 6px; color: var(--text-muted); cursor: pointer; }
.btn-icon:hover { border-color: var(--brass); color: var(--brass); }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.7); display: flex;
  align-items: center; justify-content: center; z-index: 100;
}
.modal-overlay.hidden { display: none; }
.modal {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 32px; width: 520px; max-width: 95vw; max-height: 90vh; overflow-y: auto;
}
.modal-title { font-family: 'Playfair Display', serif; font-size: 22px; margin: 0 0 24px; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  padding: 10px 14px; color: var(--text); font-size: 14px; font-family: inherit;
  box-sizing: border-box;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--brass);
}
.form-group textarea { min-height: 80px; resize: vertical; }
.form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* Project detail */
.project-detail { display: none; }
.project-detail.active { display: block; }
.project-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 32px; }
.project-title-group h2 { font-family: 'Playfair Display', serif; font-size: 28px; margin: 0 0 8px; }
.project-client-info { font-size: 14px; color: var(--text-muted); margin-bottom: 8px; }
.stage-badge {
  display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 12px;
  font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
.stage-lead { background: rgba(107,114,128,.15); color: var(--stage-lead); }
.stage-scoped { background: rgba(59,130,246,.15); color: var(--stage-scoped); }
.stage-contracted { background: rgba(139,92,246,.15); color: var(--stage-contracted); }
.stage-in_progress { background: rgba(240,165,0,.15); color: var(--stage-in-progress); }
.stage-completed { background: rgba(62,207,142,.15); color: var(--stage-completed); }

.project-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; margin-bottom: 32px; }
.project-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px; }
.project-card h3 { font-size: 13px; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin: 0 0 16px; }
.info-row { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.info-row:last-child { border-bottom: none; }
.info-label { color: var(--text-muted); }
.info-value { font-weight: 500; }
.info-value.money { color: var(--success); font-weight: 600; font-size: 18px; }

/* Milestones */
.milestones-list { list-style: none; padding: 0; margin: 0; }
.milestone-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border); font-size: 14px;
}
.milestone-item:last-child { border-bottom: none; }
.milestone-checkbox { width: 18px; height: 18px; accent-color: var(--brass); cursor: pointer; }
.milestone-text.done { text-decoration: line-through; color: var(--text-muted); }
.add-milestone-btn {
  width: 100%; padding: 8px; background: none; border: 1px dashed var(--border);
  border-radius: 6px; color: var(--text-muted); font-size: 13px; cursor: pointer; margin-top: 8px;
}
.add-milestone-btn:hover { border-color: var(--brass); color: var(--brass); }

/* Notes */
.notes-textarea { width: 100%; background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; padding: 12px; color: var(--text); font-size: 14px; font-family: inherit; min-height: 120px; resize: vertical; box-sizing: border-box; }
.notes-textarea:focus { outline: none; border-color: var(--brass); }

/* Linked items */
.linked-items { display: flex; flex-direction: column; gap: 8px; }
.linked-item {
  display: flex; align-items: center; justify-content: space-between; padding: 10px 12px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.linked-item-name { color: var(--text); font-weight: 500; }
.linked-item-empty { color: var(--text-muted); font-style: italic; }

/* Inline edit */
.inline-edit { background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer; padding: 2px 4px; border-radius: 4px; }
.inline-edit:hover { background: var(--surface2); color: var(--brass); }

/* Breadcrumb */
.breadcrumb { font-size: 13px; color: var(--text-muted); margin-bottom: 24px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--brass); }
.breadcrumb span { margin: 0 8px; }

/* Search/filter bar */
.filter-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; gap: 12px; }
.search-input {
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px 14px;
  color: var(--text); font-size: 14px; font-family: inherit; width: 280px;
}
.search-input:focus { outline: none; border-color: var(--brass); }
.filter-bar .btn { font-size: 13px; }

/* Stage move buttons */
.stage-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; }
.stage-btn {
  padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer; border: 1px solid;
  background: none; transition: all .2s; font-family: inherit;
}
.stage-btn[data-stage="lead"] { border-color: var(--stage-lead); color: var(--stage-lead); }
.stage-btn[data-stage="scoped"] { border-color: var(--stage-scoped); color: var(--stage-scoped); }
.stage-btn[data-stage="contracted"] { border-color: var(--stage-contracted); color: var(--stage-contracted); }
.stage-btn[data-stage="in_progress"] { border-color: var(--stage-in-progress); color: var(--stage-in-progress); }
.stage-btn[data-stage="completed"] { border-color: var(--stage-completed); color: var(--stage-completed); }
.stage-btn:hover { opacity: .8; }

/* Toast */
.toast {
  position: fixed; bottom: 24px; right: 24px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 12px 20px; font-size: 14px; color: var(--text); z-index: 200;
  transition: opacity .3s; box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.toast.success { border-color: var(--success); color: var(--success); }
.toast.error { border-color: var(--danger); color: var(--danger); }
.toast.hidden { opacity: 0; pointer-events: none; }

/* Responsive */
@media (max-width: 1100px) {
  .kanban-board { grid-template-columns: repeat(3, 1fr); }
  .project-grid { grid-template-columns: 1fr; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .crm-container { padding: 16px; }
  .kanban-board { grid-template-columns: 1fr 1fr; }
  .stats-bar { grid-template-columns: 1fr 1fr; }
}