/* ═══════════════════════════════════════════════
   Xperlock Lite CRM — Design System & Styles
   ═══════════════════════════════════════════════ */

/* ── Tokens ── */
:root {
  /* Brand palette */
  --brand-primary: #6c5ce7;
  --brand-primary-light: #a29bfe;
  --brand-primary-dark: #4834d4;
  --brand-accent: #00cec9;
  --brand-accent-light: #81ecec;

  /* Semantic */
  --tier-a: #00b894;
  --tier-a-bg: rgba(0, 184, 148, 0.12);
  --tier-b: #fdcb6e;
  --tier-b-bg: rgba(253, 203, 110, 0.14);
  --tier-c: #e17055;
  --tier-c-bg: rgba(225, 112, 85, 0.12);

  /* Surface */
  --bg-body: #0b0e14;
  --bg-surface: #111621;
  --bg-surface-2: #181e2c;
  --bg-surface-3: #1e2638;
  --bg-glass: rgba(17, 22, 33, 0.72);
  --bg-hover: rgba(108, 92, 231, 0.08);

  /* Text */
  --text-primary: #e8ecf4;
  --text-secondary: #8b95a8;
  --text-muted: #5a6478;

  /* Borders */
  --border: rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(108, 92, 231, 0.12);

  /* Geometry */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Sidebar */
  --sidebar-width: 240px;
  --topbar-height: 64px;
}

/* ── Reset ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* ═══════════════════════════════════════════════
   Sidebar
   ═══════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 100;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px 20px;
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  flex-shrink: 0;
}

.brand-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.brand-tag {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.sidebar-nav {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s ease;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.nav-item.active {
  background: rgba(108, 92, 231, 0.14);
  color: var(--brand-primary-light);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}

.csv-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--tier-b);
  animation: pulse-dot 1.5s infinite;
}

.status-dot.ok {
  background: var(--tier-a);
  animation: none;
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ═══════════════════════════════════════════════
   Main area
   ═══════════════════════════════════════════════ */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar ── */
.topbar {
  height: var(--topbar-height);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.menu-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
}

.page-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.01em;
  flex: 1;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  width: 260px;
  transition: border-color 0.2s;
}

.search-box:focus-within {
  border-color: var(--brand-primary);
}

.search-box svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.search-box input {
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-muted);
}

/* ── Views ── */
.view {
  display: none;
  padding: 24px 28px 40px;
  animation: fadeUp 0.3s ease;
}

.view.active {
  display: block;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ═══════════════════════════════════════════════
   KPI Cards
   ═══════════════════════════════════════════════ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(195px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}

.kpi-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, transparent 60%, var(--kpi-accent, var(--brand-primary)) 150%);
  opacity: 0.06;
  pointer-events: none;
}

.kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}

.kpi-sub {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════
   Chart Cards
   ═══════════════════════════════════════════════ */
.charts-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.chart-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
}

.chart-title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 18px;
}

/* Tier Bars */
.tier-bars {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tier-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tier-bar-label {
  width: 52px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.tier-bar-track {
  flex: 1;
  height: 28px;
  background: var(--bg-surface-3);
  border-radius: 6px;
  overflow: hidden;
  position: relative;
}

.tier-bar-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  padding-left: 10px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  min-width: 32px;
}

.tier-bar-fill.tier-a { background: linear-gradient(90deg, var(--tier-a), #55efc4); }
.tier-bar-fill.tier-b { background: linear-gradient(90deg, #f0932b, var(--tier-b)); }
.tier-bar-fill.tier-c { background: linear-gradient(90deg, var(--tier-c), #fab1a0); }

/* Funding Chart */
.funding-chart {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.funding-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.funding-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.funding-label {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}

.funding-value {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Stage Chart */
.stage-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stage-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-color {
  width: 4px;
  height: 24px;
  border-radius: 2px;
  flex-shrink: 0;
}

.stage-name {
  font-size: 12px;
  color: var(--text-secondary);
  flex: 1;
}

.stage-count {
  font-size: 13px;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════
   Section card & Data table
   ═══════════════════════════════════════════════ */
.section-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
}

.section-header h3 {
  font-size: 14px;
  font-weight: 700;
}

.badge {
  background: var(--brand-primary);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 20px;
}

.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 12px 16px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 16px;
  font-size: 13px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background 0.15s;
  cursor: pointer;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.company-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.company-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
}

.company-name-link {
  font-weight: 600;
  color: var(--text-primary);
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 24px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.tier-badge.tier-a { background: var(--tier-a-bg); color: var(--tier-a); }
.tier-badge.tier-b { background: var(--tier-b-bg); color: var(--tier-b); }
.tier-badge.tier-c { background: var(--tier-c-bg); color: var(--tier-c); }

.score-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  font-size: 13px;
}

.score-bar-mini {
  width: 40px;
  height: 5px;
  background: var(--bg-surface-3);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-mini-fill {
  height: 100%;
  border-radius: 3px;
  background: var(--brand-primary);
}

.stage-tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  background: var(--bg-surface-3);
  color: var(--text-secondary);
}

/* ═══════════════════════════════════════════════
   Leads View — Card layout
   ═══════════════════════════════════════════════ */
.controls-bar {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.filter-group label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.filter-group select {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  min-width: 140px;
  transition: border-color 0.2s;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
}

.filter-group select:focus {
  border-color: var(--brand-primary);
}

.lead-count-label {
  margin-left: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  padding-bottom: 8px;
}

.lead-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 16px;
}

.lead-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.25s, border-color 0.2s;
  position: relative;
  overflow: hidden;
}

.lead-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-light);
}

.lead-card::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  border-radius: 4px 0 0 4px;
}

.lead-card.tier-a::after { background: var(--tier-a); }
.lead-card.tier-b::after { background: var(--tier-b); }
.lead-card.tier-c::after { background: var(--tier-c); }

.lead-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}

.lead-card-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  flex-shrink: 0;
}

.lead-card-info {
  flex: 1;
  min-width: 0;
}

.lead-card-company {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-card-domain {
  font-size: 11px;
  color: var(--text-muted);
}

.lead-card-tier {
  flex-shrink: 0;
}

.lead-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 16px;
  margin-bottom: 14px;
}

.meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.meta-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.meta-value {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lead-card-trigger {
  background: var(--bg-surface-2);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.lead-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 14px;
}

.lead-card-score {
  display: flex;
  align-items: center;
  gap: 6px;
}

.score-ring {
  width: 36px;
  height: 36px;
  position: relative;
}

.score-ring svg {
  transform: rotate(-90deg);
}

.score-ring-bg {
  fill: none;
  stroke: var(--bg-surface-3);
  stroke-width: 3;
}

.score-ring-fill {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.6s ease;
}

.score-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

/* ═══════════════════════════════════════════════
   Pipeline View
   ═══════════════════════════════════════════════ */
.pipeline-board {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  align-items: start;
}

.pipeline-column {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.pipeline-col-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.pipeline-col-title {
  font-size: 13px;
  font-weight: 700;
}

.pipeline-col-count {
  font-size: 11px;
  font-weight: 700;
  background: var(--bg-surface-3);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 12px;
}

.pipeline-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

.pipeline-card {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.pipeline-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.pipeline-card-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.pipeline-card-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.pipeline-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
}

.pipeline-empty {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════
   Modal
   ═══════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeIn 0.2s ease;
}

.modal-overlay.open {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--bg-surface-3);
  border: none;
  color: var(--text-secondary);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  z-index: 2;
}

.modal-close:hover {
  background: var(--tier-c);
  color: #fff;
}

.modal-body {
  padding: 28px;
}

/* Modal sections */
.modal-hero {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.modal-avatar {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 22px;
  color: #fff;
  flex-shrink: 0;
}

.modal-company {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-domain {
  font-size: 12px;
  color: var(--brand-primary-light);
  margin-top: 2px;
}

.modal-domain a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Whose lead this is, under the name. Quieter than the domain above it: it is
   context, not the heading. */
.modal-owner {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

.modal-section {
  margin-bottom: 22px;
}

.modal-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 20px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.modal-field.full {
  grid-column: 1 / -1;
}

.modal-field-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.modal-field-value {
  font-size: 13px;
  color: var(--text-primary);
  word-break: break-word;
}

.modal-field-value a {
  color: var(--brand-primary-light);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* `.empty` is used throughout app.js to mean "this is secondary, or there is nothing
   here". It only ever had a rule for one selector, so everywhere else it relied on
   inheriting a muted colour from its container -- which worked in table cells and not
   in a plain block. One rule, so the class means the same thing wherever it is used. */
.empty {
  color: var(--text-secondary);
}

.modal-field-value.empty {
  color: var(--text-muted);
  font-style: italic;
}

.modal-score-row {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.modal-score-box {
  flex: 1;
  background: var(--bg-surface-2);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: center;
}

.modal-score-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.modal-score-num {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

/* ═══════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════ */
@media (max-width: 860px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }
  .main {
    margin-left: 0;
  }
  .menu-toggle {
    display: flex;
  }
  .search-box {
    width: 180px;
  }
  .lead-cards {
    grid-template-columns: 1fr;
  }
  .modal {
    max-width: 100%;
    border-radius: var(--radius-lg);
  }
  .modal-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--bg-surface-3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ── Utilities ── */
.text-truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ═══════════════════════════════════════════════
   Nav Divider
   ═══════════════════════════════════════════════ */
.nav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

/* ═══════════════════════════════════════════════
   Add Lead Form
   ═══════════════════════════════════════════════ */
.form-container {
  max-width: 820px;
  margin: 0 auto;
}

.form-intro {
  margin-bottom: 28px;
}

.form-intro h3 {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.form-intro p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.form-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 28px 28px;
  margin-bottom: 16px;
  transition: border-color 0.2s;
}

.form-section:focus-within {
  border-color: rgba(108, 92, 231, 0.3);
}

.form-section-header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 20px;
}

.form-section-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  flex-shrink: 0;
  margin-top: 1px;
}

.form-section-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.form-section-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-group.full {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.form-group label .required {
  color: var(--tier-c);
}

.form-group input,
.form-group select,
.form-group textarea {
  background: var(--bg-surface-2);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 13px;
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

.form-group select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6478' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}

.form-group input[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 2px;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 8px;
  padding-top: 4px;
}

.btn {
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.2s;
}

.btn-secondary {
  background: var(--bg-surface-3);
  color: var(--text-primary);
}

/* Admin screen: small in-table controls. Smaller than .btn on purpose -- these sit
   inside a data row, and a full-size button per row would read as the point of the
   table rather than as something you occasionally need. */
.admin-action {
  padding: 4px 10px;
  margin-right: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-surface-3);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
}

.admin-action:hover:not(:disabled) {
  background: var(--border-light);
}

.admin-action:disabled {
  opacity: 0.5;
  cursor: default;
}

.admin-role {
  padding: 3px 6px;
  font-size: 12px;
}

.admin-create {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--border-light);
}

.admin-create h4 {
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
}

.admin-note {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-secondary);
}

/* The status lines start empty and spend most of their life that way; without this
   they hold open a gap under the table and under the form. */
.admin-note:empty {
  display: none;
}

.admin-note code {
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--bg-surface-3);
  white-space: nowrap;
}

.btn-secondary:hover {
  background: var(--border-light);
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  color: #fff;
  box-shadow: 0 2px 8px rgba(108, 92, 231, 0.25);
}

.btn-primary:hover {
  background: linear-gradient(135deg, var(--brand-primary-light), var(--brand-primary));
  box-shadow: 0 4px 16px rgba(108, 92, 231, 0.35);
  transform: translateY(-1px);
}

/* ═══════════════════════════════════════════════
   Toast Notification
   ═══════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: var(--tier-a);
  color: #fff;
  padding: 14px 24px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 300;
  pointer-events: none;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast.error {
  background: var(--tier-c);
}

@media (max-width: 860px) {
  .form-grid {
    grid-template-columns: 1fr;
  }
  .form-section {
    padding: 18px 16px 20px;
  }
}

/* ═══════════════════════════════════════════════════════════
   Contacts — joined from contacts.csv on lead_id
   ═══════════════════════════════════════════════════════════ */

.modal-section-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  margin-left: 8px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--bg-tertiary, rgba(255, 255, 255, .06));
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
}

.contact-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.contact-card {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border, rgba(255, 255, 255, .08));
  border-radius: 10px;
  background: var(--bg-tertiary, rgba(255, 255, 255, .03));
}

.contact-card.dnc {
  opacity: .6;
  border-style: dashed;
}

.contact-avatar {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.contact-body { flex: 1; min-width: 0; }

.contact-name {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.contact-title {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
}

.contact-links {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
  font-size: 12px;
}

.contact-links a { color: var(--brand-primary); text-decoration: none; }
.contact-links a:hover { text-decoration: underline; }

.contact-note {
  margin-top: 6px;
  font-size: 11px;
  font-style: italic;
  color: var(--text-muted);
}

.contact-badge {
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}

.contact-badge.primary   { background: rgba(108, 92, 231, .18); color: #a29bfe; }
.contact-badge.dnc-badge { background: rgba(214, 48, 49, .18);  color: #ff7675; }
.contact-badge.status-verified { background: rgba(0, 184, 148, .18); color: #55efc4; }
.contact-badge.status-guessed  { background: rgba(253, 203, 110, .18); color: #ffeaa7; }
.contact-badge.status-bounced  { background: rgba(214, 48, 49, .18); color: #ff7675; }

.contact-empty {
  padding: 16px;
  border: 1px dashed var(--border, rgba(255, 255, 255, .12));
  border-radius: 10px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.contact-count {
  margin-left: auto;
  margin-right: 8px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── Add-lead form: repeating contact rows ── */

.contact-row {
  margin-bottom: 16px;
  padding: 14px;
  border: 1px solid var(--border, rgba(255, 255, 255, .08));
  border-radius: 10px;
  background: var(--bg-tertiary, rgba(255, 255, 255, .02));
}

.contact-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.contact-row-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
}

.contact-row-remove {
  padding: 3px 10px;
  border: 1px solid var(--border, rgba(255, 255, 255, .12));
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
}

.contact-row-remove:hover { color: #ff7675; border-color: #ff7675; }

.btn-secondary {
  padding: 8px 14px;
  border: 1px dashed var(--border, rgba(255, 255, 255, .18));
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.btn-secondary:hover {
  color: var(--brand-primary);
  border-color: var(--brand-primary);
}

/* Keyboard access for the cards, which are clickable divs. */
.lead-card:focus-visible,
.pipeline-card:focus-visible {
  outline: 2px solid var(--brand-primary);
  outline-offset: 2px;
}


/* ── Sprint 06: editing ─────────────────────────────────────────────────── */

/* A column shows it will accept the card being dragged over it. */
.pipeline-column.drag-over {
  outline: 2px dashed var(--accent, #4a9);
  outline-offset: -2px;
}

.pipeline-card[draggable="true"] { cursor: grab; }
.pipeline-card[draggable="true"]:active { cursor: grabbing; }

/* The stage dropdown is the keyboard route onto the board; drag is the shortcut. */
.pipeline-card-stage {
  background: var(--bg-input, #fff);
  color: var(--text-primary, #111);
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  padding: 2px 4px;
}

.edit-field {
  background: var(--bg-input, #fff);
  color: var(--text-primary, #111);
  border: 1px solid var(--border, #ccc);
  border-radius: 4px;
  padding: 5px 7px;
  font: inherit;
  font-size: 13px;
}

.edit-field:focus-visible {
  outline: 2px solid var(--accent, #4a9);
  outline-offset: 1px;
}

/* ── Update 2 sprint 02: accounts ───────────────────────────────────────── */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}

.login-card {
  width: min(380px, 92vw);
  padding: 32px;
  border: 1px solid var(--border, #2a2a35);
  border-radius: 10px;
  background: var(--bg-card, #16161d);
}

.login-title { margin: 0; font-size: 22px; font-weight: 700; }
.login-sub { margin: 4px 0 24px; font-size: 13px; color: var(--text-muted, #8a8a99); }

.login-label {
  display: block;
  margin: 14px 0 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary, #b6b6c4);
}

.login-input {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary, #f0f0f5);
  background: var(--bg-input, #0f0f14);
  border: 1px solid var(--border, #2a2a35);
  border-radius: 6px;
}

.login-input:focus-visible {
  outline: 2px solid var(--accent, #4a9);
  outline-offset: 1px;
}

.login-button {
  width: 100%;
  margin-top: 22px;
  padding: 10px;
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: var(--accent, #4a9);
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}

.login-button:disabled { opacity: 0.6; cursor: default; }

/* Hidden until there is something to say, so the form does not reserve empty space. */
.login-error {
  display: none;
  margin: 14px 0 0;
  padding: 9px 11px;
  font-size: 13px;
  color: var(--tier-c, #e06c6c);
  background: rgba(224, 108, 108, 0.08);
  border-radius: 6px;
}

.login-foot {
  margin: 22px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-muted, #8a8a99);
}

.whoami {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-left: 14px;
  font-size: 12px;
  color: var(--text-secondary, #b6b6c4);
}

.whoami-signout {
  font: inherit;
  font-size: 12px;
  color: var(--text-secondary, #b6b6c4);
  background: transparent;
  border: 1px solid var(--border, #2a2a35);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
}

.whoami-signout:hover { color: var(--text-primary, #f0f0f5); }
