/* ═══════════════════════════════════════════════════
   LeadFlow — main.css
   Palette: 5 semantic roles, no decorative extras
   ═══════════════════════════════════════════════════ */
:root {
  /* ── Surfaces ── */
  --bg:        #08090f;
  --surface:   #0f1018;
  --surface-2: #161720;
  --surface-3: #1e2030;
  --border:         rgba(255,255,255,0.07);
  --border-strong:  rgba(255,255,255,0.13);

  /* ── Typography ── */
  --text:   #edf0f7;
  --text-2: #9aa0b8;
  --text-3: #555d78;

  /* ══ 5 SEMANTIC ACCENT ROLES ══
     Everything that needs colour maps to exactly one of these.
     UI elements never reach for a raw hex — only these vars.     */

  /* 1. Primary — brand blue: CTAs, focus rings, links, active state */
  --primary:        #4070f4;
  --primary-hover:  #5a84f7;
  --primary-dim:    rgba(64, 112, 244, 0.12);
  --primary-glow:   rgba(64, 112, 244, 0.22);
  --primary-border: rgba(64, 112, 244, 0.28);

  /* 2. Accent — brand purple: AI features, "Qualified" badge, accent stripe */
  --accent:        #7c5cf6;
  --accent-hover:  #9478f8;
  --accent-dim:    rgba(124, 92, 246, 0.11);
  --accent-border: rgba(124, 92, 246, 0.22);

  /* 3. Success — green: won revenue, closed-won, positive toasts */
  --success:       #3ecf8e;
  --success-dim:   rgba(62, 207, 142, 0.11);
  --success-border:rgba(62, 207, 142, 0.22);

  /* 4. Danger — rose: overdue, errors, delete */
  --danger:        #f16b87;
  --danger-dim:    rgba(241, 107, 135, 0.11);
  --danger-border: rgba(241, 107, 135, 0.22);

  /* 5. Neutral — periwinkle: info states, "New" badge, neutral toasts,
        "Contacted" badge, proposal, non-critical indicators             */
  --neutral:        #7a9eff;
  --neutral-dim:    rgba(122, 158, 255, 0.11);
  --neutral-border: rgba(122, 158, 255, 0.22);

  /* ── Tokens ── */
  --radius:    14px;
  --radius-lg: 22px;
  --shadow:    0 20px 52px rgba(0,0,0,0.32);
  --transition: 0.17s ease;
  font-size: 15px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  color: var(--text);
  /* Background: two subtle glows echoing the logo's blue → purple */
  background:
    radial-gradient(ellipse 60% 40% at 96% 0%,   rgba(64,112,244,0.09) 0%, transparent 60%),
    radial-gradient(ellipse 50% 35% at 4%  100%,  rgba(124,92,246,0.08) 0%, transparent 55%),
    var(--bg);
  font-family: "Manrope", sans-serif;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
a, button { font: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; }
input, select, textarea { font: inherit; }

/* ══════════════ HEADER ══════════════ */
.header {
  height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  background: rgba(8,9,15,0.90);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.logo {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.logo-svg,
.logo > svg {
  width: min(148px, 44vw);
  height: auto;
  max-height: 34px;
  display: block;
  flex-shrink: 0;
  transform-origin: left center;
  animation: logoPulse 6s ease-in-out infinite;
  will-change: filter, transform;
}
@keyframes logoPulse {
  0%, 100% { filter: brightness(1);    transform: scale(1);     }
  50%       { filter: brightness(1.04); transform: scale(1.005); }
}
.logo-sub {
  color: var(--text-3);
  font-size: 12px;
  white-space: nowrap;
}
.logo-mark, .logo-name { display: none; }

.header-actions { display: flex; align-items: center; gap: 12px; }
.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-2);
  font-size: 13px;
}
.user-dot {
  width: 24px; height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  font-size: 11px;
  font-weight: 700;
}

/* ══════════════ AUTH ══════════════ */
.auth-shell, .app-shell {
  width: min(1380px, calc(100vw - 40px));
  margin: 0 auto;
}
.auth-shell {
  min-height: calc(100vh - 72px);
  display: grid;
  place-items: center;
  padding: 40px 0;
}
.auth-card {
  width: min(460px, 100%);
  background: rgba(15,16,24,0.96);
  border: 1px solid var(--border);
  border-radius: 26px;
  padding: 40px 38px;
  box-shadow: var(--shadow);
}
.auth-eyebrow, .section-title {
  color: var(--primary);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
/* Titles: Inter instead of Cormorant — enterprise-appropriate */
.auth-title, .hero-title {
  font-family: "Cormorant Garamond", serif;
  font-weight: 500;
  letter-spacing: -0.05em;
}
.auth-title {
  font-size: 2.6rem;
  line-height: 1;
}
.auth-copy {
  color: var(--text-2);
  margin: 10px 0 26px;
}
.auth-footer {
  margin-top: 18px;
  color: var(--text-2);
  font-size: 13px;
  text-align: center;
}
.link-button {
  background: none;
  border: none;
  color: var(--primary);
  padding: 0;
  font-weight: 600;
}
.link-button:hover { color: var(--primary-hover); }

/* ══════════════ APP SHELL / HERO ══════════════ */
.app-shell { padding: 34px 0 56px; }
.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 18px;
  margin-bottom: 24px;
}
.hero-kicker {
  color: var(--text-3);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.hero-title {
  font-size: clamp(3rem, 6vw, 4.4rem);
  line-height: 0.92;
}
.hero-subtitle {
  margin-top: 10px;
  color: var(--text-2);
  max-width: 60ch;
}
.hero-panel, .panel {
  background: rgba(15,16,24,0.93);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.hero-panel { padding: 22px; }
.hero-panel-title {
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}
.hero-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--primary-dim);
  border: 1px solid var(--primary-border);
  color: var(--neutral);
  font-size: 12px;
  font-weight: 500;
}

/* ══════════════ STATS GRID ══════════════
   Class names map to FUNCTION, not color.
   Each stripe maps to exactly one semantic role.       */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0,1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: rgba(15,16,24,0.93);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 20px 20px 18px;
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
}
/* Total Leads → primary */
.accent-total::before    { background: var(--primary); }
/* New → neutral */
.accent-new::before      { background: var(--neutral); }
/* Qualified → accent purple */
.accent-qualified::before { background: var(--accent); }
/* Pipeline → accent (mid-funnel) */
.accent-pipeline::before  { background: var(--accent); }
/* Won Revenue → success */
.accent-won::before       { background: var(--success); }
/* Overdue → danger */
.accent-overdue::before   { background: var(--danger); }
/* Win Rate → primary */
.accent-winrate::before   { background: var(--primary); }

/* Keep legacy class names working so HTML doesn't break */
.accent-teal::before,
.accent-brand::before   { background: var(--primary); }
.accent-blue::before    { background: var(--neutral); }
.accent-purple::before  { background: var(--accent); }
.accent-gold::before    { background: var(--accent); }
.accent-green::before   { background: var(--success); }
.accent-rose::before    { background: var(--danger); }

.stat-label {
  color: var(--text-3);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}
.stat-value {
  font-family: "DM Mono", monospace;
  font-size: 28px;
  line-height: 1;
  letter-spacing: -0.05em;
}
.stat-money { font-size: 22px; }
.stat-sub { color: var(--text-3); font-size: 12px; margin-top: 8px; }

/* ══════════════ CONTENT GRID ══════════════ */
.content-grid {
  display: grid;
  grid-template-columns: 1.45fr 0.85fr;
  gap: 18px;
  margin-bottom: 22px;
}
.panel { padding: 24px; }
.panel-head, .modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.panel-title { font-size: 1.25rem; font-weight: 700; }
.lead-form { display: block; }
.lead-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 10px;
}
.span-2 { grid-column: span 2; }
.span-4 { grid-column: span 4; }
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

/* ══════════════ REMINDER STRIP ══════════════ */
.reminder-strip {
  border-left: 3px solid var(--accent);
  padding-left: 14px;
}
.reminder-strip h3 {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.reminder-strip ul { list-style: none; display: grid; gap: 8px; }
.reminder-strip li { color: var(--text-2); font-size: 13px; }
.reminder-strip strong { color: var(--text); }

/* ══════════════ EMPTY STATE ══════════════ */
.empty-state {
  text-align: center;
  color: var(--text-3);
  padding: 40px 18px;
}
.empty-tight { padding: 28px 10px; }
.empty-icon {
  display: block;
  font-size: 28px;
  color: var(--primary);
  margin-bottom: 8px;
}

/* ══════════════ TOOLBAR ══════════════ */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.view-pills {
  display: flex;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}
.pill {
  border: none;
  background: none;
  color: var(--text-2);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 13px;
}
.pill.active {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
}
.toolbar-right { display: flex; gap: 10px; flex-wrap: wrap; }

/* ══════════════ INPUTS ══════════════ */
.input, .select, .textarea, .filter-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  padding: 11px 13px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:focus, .select:focus, .textarea:focus, .filter-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-dim);
}
.input.invalid, .select.invalid, .textarea.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-dim);
}
.label {
  display: block;
  color: var(--text-3);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 6px;
}
.form-group { margin-bottom: 16px; }
.textarea { min-height: 92px; resize: vertical; }
.select, .filter-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239aa0b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ══════════════ BUTTONS ══════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 14px;
  transition: background var(--transition), color var(--transition),
              transform var(--transition), box-shadow var(--transition);
}
.btn:active { transform: scale(0.97); }
.btn-full { width: 100%; }
/* Primary — flat brand blue, minimal shadow */
.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 10px var(--primary-glow);
}
.btn-primary:hover {
  background: var(--primary-hover);
  box-shadow: 0 3px 14px var(--primary-glow);
}
.btn-ghost {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--border-strong);
}
/* AI / accent buttons use accent purple */
.btn-ai {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}
.btn-ai:hover {
  background: rgba(124,92,246,0.18);
  color: var(--accent-hover);
}
.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid var(--danger-border);
}
.btn-danger:hover { background: rgba(241,107,135,0.18); }
.btn-sm {
  padding: 7px 13px;
  font-size: 13px;
  font-weight: 500;
}
.icon-button {
  background: none;
  border: none;
  color: var(--text-3);
  font-size: 16px;
}
.icon-button:hover { color: var(--text-2); }

/* ══════════════ LEAD LIST ══════════════ */
#list-view { display: grid; gap: 12px; }
.lead-card {
  background: rgba(15,16,24,0.93);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  display: grid;
  grid-template-columns: minmax(0,1fr) auto;
  gap: 16px;
  transition: transform var(--transition), border-color var(--transition);
}
.lead-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
}
.lead-card-main { min-width: 0; }
.lead-card-top {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}
.lead-name { font-size: 16px; font-weight: 700; }
.lead-company { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.lead-meta, .lead-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}
.lead-message, .lead-notes, .lead-ai {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 10px;
  white-space: pre-wrap;
}
/* AI summary → accent purple strip */
.lead-ai {
  padding: 12px 14px;
  background: var(--accent-dim);
  border-left: 2px solid var(--accent);
  border-radius: 0 10px 10px 0;
}
.lead-actions { display: flex; flex-direction: column; gap: 8px; }
.lead-value {
  color: var(--success);
  font-family: "DM Mono", monospace;
  font-size: 13px;
  font-weight: 500;
}
.lead-date {
  color: var(--text-3);
  font-size: 11px;
  font-family: "DM Mono", monospace;
}

/* ══════════════ BADGES
   5 pipeline states → 4 semantic roles (lost = neutral/muted)
   ══════════════ */
.badge, .source-tag, .ai-tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 9px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
/* New → neutral (early stage, no urgency) */
.badge.new {
  background: var(--neutral-dim);
  color: var(--neutral);
  border: 1px solid var(--neutral-border);
}
/* Contacted → primary blue (actively working it) */
.badge.contacted {
  background: var(--primary-dim);
  color: var(--primary-hover);
  border: 1px solid var(--primary-border);
}
/* Qualified → accent purple (high intent) */
.badge.qualified {
  background: var(--accent-dim);
  color: var(--accent-hover);
  border: 1px solid var(--accent-border);
}
/* Proposal → accent (still high intent) */
.badge.proposal {
  background: rgba(124,92,246,0.08);
  color: var(--accent);
  border: 1px solid rgba(124,92,246,0.16);
}
/* Closed Won → success */
.badge.closed-won {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid var(--success-border);
}
/* Closed Lost → muted/neutral */
.badge.closed-lost {
  background: rgba(255,255,255,0.04);
  color: var(--text-3);
  border: 1px solid rgba(255,255,255,0.07);
}

.source-tag { background: var(--surface-3); color: var(--text-2); }
/* AI tags → accent purple */
.ai-tag {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid var(--accent-border);
}

/* ══════════════ PRIORITY DOTS ══════════════ */
.priority-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.priority-high   { background: var(--danger); }
.priority-medium { background: var(--primary); }
.priority-low    { background: var(--text-3); }

/* ══════════════ KANBAN BOARD ══════════════ */
.board {
  display: grid;
  grid-template-columns: repeat(6, minmax(0,1fr));
  gap: 12px;
}
.board-col {
  background: rgba(15,16,24,0.93);
  border: 1px solid var(--border);
  border-radius: 20px;
  min-height: 240px;
  display: flex;
  flex-direction: column;
}
.board-col.drag-over {
  border-color: var(--primary-border);
  background: rgba(20,22,36,0.98);
}
.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-2);
}
.board-count {
  background: var(--surface-3);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}
.board-cards { padding: 10px; display: grid; gap: 8px; flex: 1; }
.board-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  cursor: grab;
  transition: border-color var(--transition), transform var(--transition);
}
.board-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-1px);
}
.board-card.dragging { opacity: 0.35; }
.board-card-name { font-size: 13px; font-weight: 700; }
.board-card-meta { color: var(--text-3); font-size: 11px; margin-top: 4px; }
.board-card-value {
  color: var(--success);
  font-family: "DM Mono", monospace;
  font-size: 12px;
  margin-top: 6px;
}

/* ══════════════ MODAL ══════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.76);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
}
.modal-card {
  width: min(820px, 100%);
  background: rgba(13,14,22,0.98);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.modal-title { font-size: 22px; font-weight: 700; }

/* ══════════════ TOASTS ══════════════ */
.toast-container {
  position: fixed;
  top: 18px; right: 18px;
  z-index: 100;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 36px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid;
  backdrop-filter: blur(14px);
  animation: slide-in 0.22s ease;
  font-size: 13px;
  font-weight: 500;
}
.toast-success {
  background: var(--success-dim);
  border-color: var(--success-border);
  color: var(--success);
}
.toast-error {
  background: var(--danger-dim);
  border-color: var(--danger-border);
  color: var(--danger);
}
.toast-info {
  background: var(--primary-dim);
  border-color: var(--primary-border);
  color: var(--primary-hover);
}
.toast-warn {
  background: var(--accent-dim);
  border-color: var(--accent-border);
  color: var(--accent-hover);
}
.toast-msg { flex: 1; }
.toast-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.55;
}
.toast-close:hover { opacity: 1; }

/* ══════════════ UTILITIES ══════════════ */
.hidden { display: none !important; }
@keyframes slide-in {
  from { opacity: 0; transform: translateX(18px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ══════════════ RESPONSIVE ══════════════ */
@media (max-width: 1280px) {
  .stats-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .board      { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 980px) {
  .hero, .content-grid   { grid-template-columns: 1fr; }
  .lead-grid             { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .board                 { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 720px) {
  .auth-shell, .app-shell { width: min(100vw - 24px, 1380px); }
  .header     { padding: 0 14px; }
  .stats-grid, .lead-grid, .board { grid-template-columns: 1fr; }
  .span-2, .span-4 { grid-column: span 1; }
  .lead-card  { grid-template-columns: 1fr; }
  .lead-actions { flex-direction: row; flex-wrap: wrap; }
}