/* ===================================================================
   LeadFlow — freelance sales CRM
   Palette: near-black surfaces, one signal accent (spring green) for
   progress/won, qualitative stage hues carried through column headers
   and badges as chevrons — the pipeline's "flow" made literal.
   Type: Space Grotesk (display) / Inter (body) / JetBrains Mono (data)
   =================================================================== */

:root{
  --bg: #0B0D12;
  --surface: #12151C;
  --surface-2: #171B24;
  --surface-3: #1E232E;
  --border: #262C39;
  --text: #E7E9EE;
  --text-dim: #9AA1B2;
  --text-faint: #656C7E;

  --accent: #3DDC97;
  --accent-dim: #2A9D6F;
  --danger: #F0556B;
  --warn: #F5A623;

  --stage-blue: #5B8DEF;
  --stage-cyan: #33C1D9;
  --stage-teal: #29C6A6;
  --stage-amber: #F0B429;
  --stage-violet: #9B7DEF;
  --stage-orange: #F2843C;
  --stage-green: #3DDC97;
  --stage-red: #F0556B;
  --stage-gray: #8891A5;

  --radius: 10px;
  --radius-lg: 16px;
  --font-display: 'Space Grotesk', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;
}

*{ box-sizing: border-box; }
html{ color-scheme: dark; }
body{
  margin:0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}
h1,h2,h3,h4{ font-family: var(--font-display); margin:0; letter-spacing: -0.01em; }
button{ font-family: inherit; }
a{ color: var(--accent); }

::selection{ background: var(--accent); color: #062017; }

/* focus visibility */
:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------- layout shell ---------------- */
.app-shell{ min-height: 100vh; display:flex; flex-direction:column; }

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  position: sticky; top:0; z-index:20;
}
.brand{ display:flex; align-items:center; gap:10px; font-family:var(--font-display); font-weight:700; font-size:19px; }
.brand-mark{ color: var(--accent); display:flex; }
.topbar-actions{ display:flex; align-items:center; gap:10px; }
.user-menu{ display:flex; align-items:center; gap:8px; margin-left:6px; padding-left:14px; border-left:1px solid var(--border); }
.user-name{ font-size:12.5px; color: var(--text-dim); font-weight:600; max-width:140px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

.main{ flex:1; padding: 22px 28px 40px; max-width: 1520px; margin: 0 auto; width:100%; }

/* ---------------- buttons ---------------- */
.btn{
  border:1px solid var(--border); background: var(--surface-2); color: var(--text);
  padding: 9px 16px; border-radius: var(--radius); font-size:13.5px; font-weight:600;
  cursor:pointer; transition: all .15s ease; white-space:nowrap;
}
.btn:hover{ background: var(--surface-3); border-color:#333a4a; }
.btn-primary{ background: var(--accent); border-color: var(--accent); color:#052018; }
.btn-primary:hover{ background:#4EE8A6; border-color:#4EE8A6; }
.btn-ghost{ background:transparent; }
.btn-danger-ghost{ background:transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger-ghost:hover{ background: rgba(240,85,107,.1); }
.btn-sm{ padding: 7px 12px; font-size:12.5px; }

/* ---------------- stat cards ---------------- */
.stats-row{
  display:grid; grid-template-columns: repeat(6, 1fr); gap: 12px; margin-bottom: 20px;
}
.stat-card{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px; display:flex; flex-direction:column; gap:6px;
}
.stat-label{ font-size:11.5px; color: var(--text-dim); text-transform:uppercase; letter-spacing:.06em; font-weight:600; }
.stat-value{ font-family: var(--font-mono); font-size:22px; font-weight:700; }
.stat-card.accent-green .stat-value{ color: var(--accent); }
.stat-card.accent-red .stat-value{ color: var(--danger); }

/* ---------------- charts ---------------- */
.charts-row{ display:grid; grid-template-columns: 1.6fr 1fr 1fr; gap: 14px; margin-bottom: 22px; }
.panel{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-lg);
  padding: 16px 18px;
}
.panel-chart{ min-height: 230px; }
.panel-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.panel-head h2{ font-size:14.5px; font-weight:600; }
.panel-sub{ font-size:11.5px; color: var(--text-faint); }

.segmented{ display:flex; border:1px solid var(--border); border-radius:8px; overflow:hidden; }
.segmented button{
  background:transparent; border:none; color:var(--text-dim); padding:5px 10px; font-size:12px; cursor:pointer;
}
.segmented button.active{ background: var(--surface-3); color: var(--text); }

/* ---------------- board layout ---------------- */
.board-layout{ display:grid; grid-template-columns: 1fr 300px; gap: 16px; align-items:start; }
.board-wrap{ overflow-x:auto; padding-bottom: 8px; }
.board{ display:flex; gap:14px; min-width: max-content; }

.board-col{ width: 272px; flex-shrink:0; display:flex; flex-direction:column; }

/* chevron column header — the pipeline's flow made literal */
.col-head{
  position: relative;
  padding: 10px 16px 10px 22px;
  color:#04140F; font-weight:700; font-size:13px;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 0 100%, 10px 50%);
  margin-left: -10px;
  display:flex; align-items:center; justify-content:space-between;
}
.col-head .col-count{ font-family: var(--font-mono); font-size:12px; opacity:.85; }
.col-head .col-value{ display:block; font-family:var(--font-mono); font-size:10.5px; opacity:.8; font-weight:600; }

.col-head[data-color="blue"]{ background: var(--stage-blue); }
.col-head[data-color="cyan"]{ background: var(--stage-cyan); }
.col-head[data-color="teal"]{ background: var(--stage-teal); }
.col-head[data-color="amber"]{ background: var(--stage-amber); }
.col-head[data-color="violet"]{ background: var(--stage-violet); }
.col-head[data-color="orange"]{ background: var(--stage-orange); }
.col-head[data-color="green"]{ background: var(--stage-green); }
.col-head[data-color="red"]{ background: var(--stage-red); }
.col-head[data-color="gray"]{ background: var(--stage-gray); }

.col-body{
  background: var(--surface); border:1px solid var(--border); border-top:none; border-radius: 0 0 12px 12px;
  padding: 10px; display:flex; flex-direction:column; gap:10px; min-height: 140px; flex:1;
}
.col-body.drag-over{ background: var(--surface-2); outline: 1px dashed var(--accent); outline-offset: -4px; }

/* ---------------- lead cards ---------------- */
.lead-card{
  background: var(--surface-2); border:1px solid var(--border); border-radius: var(--radius);
  padding: 12px 13px; cursor:grab; transition: border-color .15s, transform .1s;
}
.lead-card:hover{ border-color:#3a4257; }
.lead-card:active{ cursor:grabbing; }
.lead-card.dragging{ opacity:.4; }

.lead-card-top{ display:flex; justify-content:space-between; align-items:flex-start; gap:8px; margin-bottom:6px; }
.lead-card-name{ font-weight:600; font-size:13.5px; }
.lead-card-company{ font-size:11.5px; color: var(--text-dim); }
.lead-card-value{ font-family: var(--font-mono); font-weight:700; font-size:13px; color: var(--accent); white-space:nowrap; }

.lead-card-meta{ display:flex; flex-wrap:wrap; gap:5px; margin-top:8px; }
.tag{
  font-size:10.5px; padding:2px 7px; border-radius:5px; background: var(--surface-3);
  color: var(--text-dim); border:1px solid var(--border); font-weight:500;
}
.tag-priority-High, .tag-priority-Urgent{ color: var(--warn); border-color: rgba(245,166,35,.4); }
.tag-priority-Urgent{ color: var(--danger); border-color: rgba(240,85,107,.4); }

.lead-card-score{
  margin-top:8px; height:4px; border-radius:2px; background: var(--surface-3); overflow:hidden;
}
.lead-card-score-fill{ height:100%; background: var(--accent); }

.col-empty{ color: var(--text-faint); font-size:12px; text-align:center; padding: 18px 6px; border:1px dashed var(--border); border-radius:8px; }

/* ---------------- sidebar ---------------- */
.sidebar{ display:flex; flex-direction:column; gap:14px; }
.action-list, .lead-score-list, .manage-list{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:8px; }
.action-list li, .lead-score-list li{
  display:flex; align-items:center; gap:8px; font-size:12.5px; padding:8px 10px;
  background: var(--surface-2); border-radius:8px; border:1px solid var(--border);
}
.action-list li.overdue{ border-color: rgba(240,85,107,.4); }
.action-list .action-check{ width:16px; height:16px; flex-shrink:0; accent-color: var(--accent); cursor:pointer; }
.action-list .action-text{ flex:1; }
.action-list .action-due{ color: var(--text-faint); font-family: var(--font-mono); font-size:11px; }
.lead-score-list .score-badge{
  font-family: var(--font-mono); font-weight:700; font-size:12px; color:#04140F;
  background: var(--accent); border-radius:6px; padding:2px 6px; flex-shrink:0;
}
.lead-score-list .score-name{ flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; cursor:pointer; }
.lead-score-list .score-value{ font-family: var(--font-mono); font-size:11.5px; color: var(--text-dim); }

.mini-table{ width:100%; border-collapse:collapse; font-size:12px; }
.mini-table th{ text-align:left; color: var(--text-faint); font-weight:600; font-size:10.5px; text-transform:uppercase; letter-spacing:.04em; padding-bottom:8px; }
.mini-table td{ padding:6px 0; border-top:1px solid var(--border); }
.mini-table td:not(:first-child){ font-family: var(--font-mono); text-align:right; }

.empty{ color: var(--text-faint); font-size:12px; text-align:center; padding: 8px; }

/* ---------------- modals ---------------- */
.modal-overlay{
  display:none; position:fixed; inset:0; background: rgba(4,6,10,.7); backdrop-filter: blur(2px);
  align-items:center; justify-content:center; z-index:100; padding: 20px;
}
.modal-overlay.open{ display:flex; }
.modal{
  background: var(--surface); border:1px solid var(--border); border-radius: var(--radius-lg);
  width: 100%; max-width: 480px; max-height: 88vh; display:flex; flex-direction:column; overflow:hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.modal-lg{ max-width: 640px; }
.modal-head{
  display:flex; align-items:center; justify-content:space-between; padding: 16px 20px;
  border-bottom:1px solid var(--border);
}
.modal-close{ background:none; border:none; color: var(--text-dim); font-size:22px; cursor:pointer; line-height:1; }
.modal-body{ padding: 18px 20px; overflow-y:auto; }
.modal-foot{ padding: 14px 20px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:10px; }
.modal-foot-split{ justify-content:space-between; }

.form-grid{ display:grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.field{ display:flex; flex-direction:column; gap:5px; font-size:12.5px; color: var(--text-dim); font-weight:500; }
.field-wide{ grid-column: 1 / -1; }
.field input, .field select, .field textarea{
  background: var(--surface-2); border:1px solid var(--border); border-radius:8px; color: var(--text);
  padding: 9px 10px; font-size:13px; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus{ border-color: var(--accent); }
.field textarea{ resize:vertical; }

.inline-add-form{ display:flex; gap:8px; margin-bottom:14px; }
.inline-add-form input{
  flex:1; background: var(--surface-2); border:1px solid var(--border); border-radius:8px; color: var(--text); padding:9px 10px; font-size:13px;
}
.manage-list li{
  display:flex; justify-content:space-between; align-items:center; padding: 8px 10px;
  background: var(--surface-2); border:1px solid var(--border); border-radius:8px; font-size:13px;
}
.manage-list .remove-btn{ background:none; border:none; color: var(--text-faint); cursor:pointer; font-size:16px; }
.manage-list .remove-btn:hover{ color: var(--danger); }

/* lead detail modal */
.detail-summary{ display:flex; flex-wrap:wrap; gap: 8px 18px; margin-bottom: 16px; font-size:12.5px; color: var(--text-dim); }
.detail-summary strong{ color: var(--text); }
.activity-form{ display:flex; gap:8px; margin-bottom:16px; flex-wrap:wrap; }
.activity-form select{ background: var(--surface-2); border:1px solid var(--border); border-radius:8px; color:var(--text); padding:8px 10px; font-size:12.5px; }
.activity-form input[type="text"]{ flex:1; min-width:160px; background: var(--surface-2); border:1px solid var(--border); border-radius:8px; color:var(--text); padding:8px 10px; font-size:12.5px; }
.activity-form input[type="date"]{ background: var(--surface-2); border:1px solid var(--border); border-radius:8px; color:var(--text); padding:8px 10px; font-size:12.5px; }

.timeline-heading{ font-size:12.5px; text-transform:uppercase; letter-spacing:.05em; color: var(--text-faint); margin-bottom:10px; }
.timeline{ list-style:none; margin:0; padding:0; display:flex; flex-direction:column; gap:10px; max-height:260px; overflow-y:auto; }
.timeline li{ padding:10px 12px; background: var(--surface-2); border-radius:8px; border-left:3px solid var(--accent); font-size:12.5px; }
.timeline .t-title{ font-weight:600; }
.timeline .t-meta{ color: var(--text-faint); font-size:11px; margin-top:3px; font-family: var(--font-mono); }
.timeline .t-desc{ color: var(--text-dim); margin-top:4px; }

/* toast */
.toast{
  position:fixed; bottom:20px; left:50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-3); border:1px solid var(--border); color: var(--text);
  padding: 10px 18px; border-radius: 10px; font-size:13px; opacity:0; pointer-events:none;
  transition: all .2s ease; z-index:200;
}
.toast.show{ opacity:1; transform: translateX(-50%) translateY(0); }
.toast.error{ border-color: var(--danger); color:#FFB4C0; }

/* ---------------- responsive ---------------- */
@media (max-width: 1200px){
  .stats-row{ grid-template-columns: repeat(3,1fr); }
  .charts-row{ grid-template-columns: 1fr; }
  .board-layout{ grid-template-columns: 1fr; }
}
@media (max-width: 640px){
  .stats-row{ grid-template-columns: repeat(2,1fr); }
  .form-grid{ grid-template-columns: 1fr; }
  .topbar{ flex-direction:column; gap:10px; align-items:flex-start; }
}

/* ---------------- auth pages (login / register) ---------------- */
.auth-page{
  min-height:100vh; display:flex; align-items:center; justify-content:center;
  background: radial-gradient(ellipse at top, #171B24 0%, var(--bg) 60%);
  padding: 20px;
}
.auth-card{
  width:100%; max-width: 380px; background: var(--surface); border:1px solid var(--border);
  border-radius: var(--radius-lg); padding: 30px 28px; box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
.auth-brand{ display:flex; align-items:center; gap:9px; font-family:var(--font-display); font-weight:700; font-size:18px; color: var(--accent); margin-bottom:22px; }
.auth-brand span:last-child{ color: var(--text); }
.auth-card h1{ font-size:21px; margin-bottom:4px; }
.auth-sub{ color: var(--text-dim); font-size:12.5px; margin: 0 0 20px; }
.auth-form{ display:flex; flex-direction:column; gap:14px; }
.auth-form .field input{ padding:10px 11px; }
.btn-block{ width:100%; padding:11px; margin-top:4px; }
.auth-switch{ text-align:center; font-size:12.5px; color: var(--text-dim); margin: 18px 0 0; }
.auth-switch a{ font-weight:600; }
.auth-errors{
  background: rgba(240,85,107,.1); border:1px solid rgba(240,85,107,.35); color:#FFB4C0;
  border-radius:8px; padding:10px 12px; font-size:12.5px; margin-bottom:16px; display:flex; flex-direction:column; gap:4px;
}
