/* =========================================================================
   DESIGN SYSTEM & THEME TOKENS — PREMIUM DARK GLASSMORPHISM
   ========================================================================= */
:root {
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --bg-primary: #070913;
  --bg-secondary: #0e1322;
  --bg-tertiary: #161e36;
  --card-bg: rgba(18, 26, 47, 0.7);
  --card-hover: rgba(28, 39, 68, 0.85);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-border-hover: rgba(59, 130, 246, 0.35);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --shadow-card: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-glow-blue: 0 0 35px rgba(59, 130, 246, 0.25);
  --shadow-glow-cyan: 0 0 35px rgba(6, 182, 212, 0.25);
}

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

body {
  font-family: var(--font-body);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Ambient Glows */
.bg-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
}
.glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.15), transparent 70%);
  top: -100px;
  left: 10%;
}
.glow-2 {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.12), transparent 70%);
  bottom: 0;
  right: 5%;
}
.glow-3 {
  width: 400px;
  height: 400px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.1), transparent 70%);
  top: 40%;
  left: 45%;
}

.app-layout {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* TOP NAV */
.top-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.2rem 2.5rem;
  background: rgba(14, 19, 34, 0.8);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--glass-border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.version-badge {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  background: rgba(59, 130, 246, 0.18);
  color: #93c5fd;
  border: 1px solid rgba(59, 130, 246, 0.3);
  border-radius: var(--radius-full);
}

.brand-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.nav-controls {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.circuit-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-full);
  color: #6ee7b7;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.status-dot.green {
  background: #10b981;
  box-shadow: 0 0 10px #10b981;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-body);
  font-size: 0.92rem;
  font-weight: 600;
  padding: 0.65rem 1.3rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb 0%, #06b6d4 100%);
  color: #ffffff;
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.35);
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(37, 99, 235, 0.5);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--glass-border);
}
.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

.btn-emerald {
  background: linear-gradient(135deg, #059669 0%, #10b981 100%);
  color: white;
}
.btn-emerald:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.4);
}

.btn-rose {
  background: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%);
  color: white;
}

/* STATS OVERVIEW BAR */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.2rem;
  padding: 1.8rem 2.5rem 0.8rem;
}

.stat-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.2rem 1.4rem;
  display: flex;
  align-items: center;
  gap: 1.1rem;
  transition: border-color 0.2s, transform 0.2s;
}
.stat-card:hover {
  border-color: var(--glass-border-hover);
  transform: translateY(-2px);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-cyan { background: rgba(6, 182, 212, 0.15); color: #22d3ee; }
.icon-purple { background: rgba(139, 92, 246, 0.15); color: #c084fc; }
.icon-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }
.icon-emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.icon-green { background: rgba(34, 197, 94, 0.15); color: #4ade80; }

.stat-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
  color: #ffffff;
  margin-top: 0.15rem;
}

/* KANBAN BOARD */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(280px, 1fr));
  gap: 1.2rem;
  padding: 1.5rem 2.5rem 2.5rem;
  overflow-x: auto;
}

.kanban-column {
  background: rgba(14, 19, 34, 0.5);
  backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  min-height: 550px;
  max-height: 80vh;
}

.kanban-column.highlighted {
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.03);
  box-shadow: 0 0 25px rgba(16, 185, 129, 0.08);
}

.column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.1rem 1.2rem;
  border-bottom: 1px solid var(--glass-border);
}

.col-title {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.col-title h3 {
  font-family: var(--font-display);
  font-size: 0.98rem;
  font-weight: 700;
}

.pill {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}
.pill-blue { background: #1d4ed8; color: white; }
.pill-purple { background: #6d28d9; color: white; }
.pill-cyan { background: #0e7490; color: white; }
.pill-emerald { background: #047857; color: white; }
.pill-slate { background: #334155; color: white; }

.count-badge {
  background: var(--bg-tertiary);
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.column-content {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

/* LEAD CARD */
.lead-card {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}
.lead-card:hover {
  background: var(--card-hover);
  border-color: var(--glass-border-hover);
  transform: translateY(-3px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

.lead-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.lead-card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1.3;
}

.lead-status-chip {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.status-INGESTED { background: rgba(59, 130, 246, 0.15); color: #93c5fd; }
.status-AUDITED_QUALIFIED { background: rgba(139, 92, 246, 0.15); color: #c084fc; }
.status-DISCARDED { background: rgba(100, 116, 139, 0.15); color: #94a3b8; }
.status-PROPOSAL_COMPILED { background: rgba(6, 182, 212, 0.15); color: #67e8f9; }
.status-DEMO_DEPLOYED { background: rgba(168, 85, 247, 0.2); color: #d8b4fe; border: 1px solid rgba(168, 85, 247, 0.4); }
.status-FLAGGED_FOR_REVIEW { background: rgba(245, 158, 11, 0.2); color: #fde047; border: 1px solid rgba(245, 158, 11, 0.4); }
.status-QUEUED { background: rgba(59, 130, 246, 0.2); color: #93c5fd; }
.status-SENT { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; }
.status-REPLIED { background: rgba(236, 72, 153, 0.2); color: #f472b6; font-weight: 800; }
.status-HUMAN_HANDOFF { background: linear-gradient(90deg, rgba(16, 185, 129, 0.3), rgba(6, 182, 212, 0.3)); color: #34d399; font-weight: 800; border: 1px solid #10b981; }
.status-WON { background: rgba(34, 197, 94, 0.25); color: #4ade80; border: 1px solid #22c55e; }
.status-LOST { background: rgba(244, 63, 94, 0.2); color: #fda4af; }

.lead-meta {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 0.7rem;
}

.rating-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: #facc15;
  font-weight: 700;
}

.lead-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.7rem;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 0.78rem;
  color: var(--text-muted);
}

.tag {
  background: var(--bg-tertiary);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  font-size: 0.72rem;
}

/* MODALS */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 16, 0.85);
  backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1.5rem;
}
.modal-backdrop.active {
  display: flex;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--glass-border-hover);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 550px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
  animation: modalAppear 0.25s ease-out;
}
.modal-card.modal-lg {
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

@keyframes modalAppear {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem 1.8rem;
  border-bottom: 1px solid var(--glass-border);
}
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 1.35rem;
}
.modal-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}
.modal-close:hover { color: #ffffff; }

.modal-body {
  padding: 1.8rem;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 1.2rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}
.form-group input {
  width: 100%;
  background: var(--bg-tertiary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 0.95rem;
}
.form-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--glass-border);
}

/* SPINNER */
.btn-spinner {
  display: none;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.btn-spinner.active { display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* LEAD DETAIL MODAL STYLES */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 768px) {
  .detail-grid { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
}

.detail-section {
  background: var(--card-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 1.3rem;
}

.detail-section h4 {
  font-family: var(--font-display);
  font-size: 1rem;
  margin-bottom: 0.8rem;
  color: #93c5fd;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.audit-metric-row {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  font-size: 0.9rem;
}
.metric-name { color: var(--text-secondary); }
.metric-val { font-weight: 700; color: #ffffff; }

.screenshot-preview {
  width: 100%;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  max-height: 220px;
  object-fit: cover;
  margin-top: 0.8rem;
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}
.chip {
  background: rgba(59, 130, 246, 0.15);
  color: #bfdbfe;
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-full);
  border: 1px solid rgba(59, 130, 246, 0.25);
}

.copy-box {
  background: var(--bg-primary);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 0.9rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: #e2e8f0;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 160px;
  overflow-y: auto;
  margin-bottom: 0.8rem;
}

.human-actions {
  display: flex;
  gap: 0.8rem;
  margin-top: 1.2rem;
}
