/* --- Global CSS Variables & Minimalist Design System --- */
:root {
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-subtle: #f1f5f9;
  --bg-hover: #e2e8f0;
  
  --border-color: #e2e8f0;
  --border-focus: #0a66c2;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  --brand-blue: #0a66c2;
  --brand-blue-hover: #004182;
  --brand-blue-light: #e8f3fc;

  --success-emerald: #10b981;
  --success-light: #ecfdf5;
  --success-text: #065f46;

  --warning-amber: #f59e0b;
  --warning-light: #fef3c7;
  --warning-text: #92400e;

  --danger-rose: #ef4444;
  --danger-light: #fef2f2;
  --danger-text: #991b1b;

  --stalled-slate: #64748b;
  --stalled-light: #f1f5f9;
  --stalled-text: #334155;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-modal: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  padding: 24px 16px;
  min-height: 100vh;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* --- Header --- */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
  gap: 12px;
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-logo-img {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  box-shadow: 0 2px 8px rgba(10, 102, 194, 0.28);
  flex-shrink: 0;
  display: block;
}

.auth-brand-logo-img {
  width: 44px;
  height: 44px;
  border-radius: 11px;
  box-shadow: 0 4px 14px rgba(10, 102, 194, 0.32);
  flex-shrink: 0;
  display: block;
}

.brand-icon {
  color: var(--brand-blue);
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.brand-subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.date-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.825rem;
  font-weight: 500;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}

/* --- Server Status Pill --- */
.server-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: #166534;
  box-shadow: var(--shadow-sm);
}

.status-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #22c55e;
  box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0);
  }
}

/* --- User Auth Widget & Logout --- */
.user-auth-widget {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.user-email-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
  transform: translateY(-1px);
}

/* --- Authentication Gate Overlay --- */
.auth-gate-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: radial-gradient(circle at 50% 30%, #1e293b 0%, #0f172a 100%);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
}

.auth-gate-card {
  background: #ffffff;
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.1);
  padding: 32px 28px;
  position: relative;
  animation: authFadeUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authFadeUp {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.auth-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #f1f5f9;
}

.auth-brand-badge {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-brand-badge .brand-icon {
  color: #0a66c2;
  flex-shrink: 0;
}

.auth-brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em;
}

.auth-security-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #475569;
}

.auth-step-heading {
  margin-bottom: 22px;
}

.auth-step-heading h2 {
  font-size: 1.35rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}

.auth-step-heading p {
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.5;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-input-icon {
  position: absolute;
  left: 14px;
  color: #94a3b8;
  pointer-events: none;
}

.auth-input-wrap input {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1.5px solid #cbd5e1;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-input-wrap input:focus {
  border-color: #0a66c2;
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.15);
}

.otp-input-group {
  margin: 12px 0 6px;
}

.otp-main-input {
  width: 100%;
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.8rem;
  font-weight: 700;
  letter-spacing: 12px;
  padding: 12px 16px;
  border: 2px solid #cbd5e1;
  border-radius: 12px;
  color: #0a66c2;
  background: #f8fafc;
  outline: none;
  transition: all 0.2s;
}

.otp-main-input:focus {
  border-color: #0a66c2;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(10, 102, 194, 0.18);
}

.auth-error-msg {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.825rem;
  font-weight: 500;
  margin: 14px 0;
  line-height: 1.4;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.auth-submit-btn {
  width: 100%;
  padding: 12px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 18px;
  box-shadow: 0 4px 12px rgba(10, 102, 194, 0.25);
  cursor: pointer;
}

.auth-step-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #f1f5f9;
}

/* --- Workload Target Card (Hero) --- */
.target-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 32px;
  align-items: center;
}

.target-left {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.target-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.target-label {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.target-info-tag {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--brand-blue);
  background: var(--brand-blue-light);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
}

.target-input-row {
  display: flex;
  gap: 10px;
}

.target-input {
  flex: 1;
  padding: 8px 14px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-subtle);
  transition: var(--transition);
}

.target-input:focus {
  outline: none;
  background: var(--bg-card);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.12);
}

.target-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.progress-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.count-statement {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.highlight-added {
  color: var(--brand-blue);
}

.highlight-left {
  color: var(--warning-text);
}

.percent-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--bg-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
}

.progress-bar-track {
  width: 100%;
  height: 10px;
  background: var(--bg-subtle);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #0a66c2 0%, #004182 100%);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

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

/* --- Content Grid --- */
.content-grid {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 20px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* --- Lead Form --- */
.lead-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-prefix-svg {
  position: absolute;
  left: 12px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrap input {
  width: 100%;
  padding: 9px 65px 9px 36px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-card);
  transition: var(--transition);
}

.input-wrap input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.12);
}

.btn-input-action {
  position: absolute;
  right: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition);
}

.btn-input-action:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.form-hint {
  font-size: 0.725rem;
  color: var(--text-muted);
}

.form-row {
  display: flex;
  gap: 12px;
}

.flex-1 { flex: 1; }

.date-col { width: 140px; }

.form-row input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-card);
  transition: var(--transition);
}

.form-row input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.12);
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
}

.form-footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.default-tick-note {
  font-size: 0.775rem;
  font-weight: 600;
  color: var(--success-text);
  background: var(--success-light);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.tick-icon {
  font-weight: 800;
}

/* Color selector group */
.lead-color-picker-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-picker-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.color-choice-btn {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: transparent;
  padding: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.color-choice-btn.active {
  border-color: #0f172a;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.color-dot.green { background-color: #10b981; }
.color-dot.red { background-color: #ef4444; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-sans);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
}

.btn-primary {
  background: var(--brand-blue);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--brand-blue-hover);
}

.btn-secondary {
  background: var(--bg-subtle);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background: var(--bg-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.775rem;
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--brand-blue);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}

.btn-link:hover {
  text-decoration: underline;
}

/* --- Metrics Grid --- */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: var(--transition);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: #cbd5e1;
}

.metric-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-total { background: #eff6ff; }
.metric-today { background: #fef3c7; }
.metric-qualified { background: #ecfdf5; }
.metric-stalled { background: #f1f5f9; }

.metric-body {
  display: flex;
  flex-direction: column;
}

.metric-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric-val {
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

/* --- Table & Views Section --- */
.table-card {
  padding: 0;
  overflow: hidden;
}

.table-header-controls {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.view-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 10px;
  overflow-x: auto;
}

.tab-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  font-family: var(--font-sans);
  color: var(--text-secondary);
  border-radius: var(--radius-full);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--brand-blue-light);
  color: var(--brand-blue);
  font-weight: 700;
}

.tab-btn.connection-tab.active {
  background: #eff6ff;
  color: var(--brand-blue);
  border: 1px solid #bfdbfe;
}

.tab-btn.starred-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.tab-btn.starred-tab.active {
  background: #fef3c7;
  color: #b45309;
  border: 1px solid #fde68a;
}

.tab-star-icon {
  flex-shrink: 0;
}

.tab-btn.qualified-tab.active {
  background: var(--success-light);
  color: var(--success-text);
}

.tab-count {
  font-size: 0.725rem;
  padding: 1px 7px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: var(--radius-full);
}

.tab-btn.active .tab-count {
  background: rgba(10, 102, 194, 0.15);
}

.tab-btn.starred-tab.active .tab-count {
  background: rgba(217, 119, 6, 0.18);
}

.table-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}

.date-filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.filter-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.filter-date-input {
  padding: 6px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-family: var(--font-sans);
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.filter-date-input:focus {
  outline: none;
  background: var(--bg-card);
  border-color: var(--border-focus);
}

.date-filter-count-pill {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--brand-blue);
  background: var(--brand-blue-light);
  padding: 3px 8px;
  border-radius: var(--radius-full);
}

.search-box {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  max-width: 320px;
}

.search-icon-svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  padding: 7px 12px 7px 32px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.825rem;
  font-family: var(--font-sans);
  background: var(--bg-subtle);
  color: var(--text-primary);
  transition: var(--transition);
}

.search-box input:focus {
  outline: none;
  background: var(--bg-card);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(10, 102, 194, 0.12);
}

.export-group {
  display: flex;
  gap: 6px;
}

.filter-notice {
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.825rem;
  color: var(--text-secondary);
}

.filter-notice-content {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Table Styles (Desktop) --- */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.leads-table th {
  background: #fafafa;
  padding: 12px 16px;
  font-size: 0.775rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border-color);
}

.leads-table td {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.leads-table tbody tr:hover {
  background-color: #f8fafc;
}

/* Lead Name Cell */
.lead-name-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-color-dot {
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.btn-color-dot.is-green .status-dot {
  background-color: #10b981;
}

.btn-color-dot.is-red .status-dot {
  background-color: #ef4444;
}

.lead-name-text {
  font-weight: 600;
  color: var(--text-primary);
}

.lead-name-text.is-red {
  color: #dc2626 !important;
}

.lead-date-pill {
  font-family: var(--font-mono);
  font-size: 0.775rem;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
}

.lead-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--brand-blue);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.825rem;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lead-link:hover {
  text-decoration: underline;
}

.link-icon {
  font-size: 0.75rem;
}

/* Star Button */
.btn-star-lead {
  background: transparent;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: transform 0.15s ease;
}

.btn-star-lead:hover {
  transform: scale(1.15);
}

.btn-star-lead.is-starred svg {
  fill: #f59e0b;
  stroke: #d97706;
}

/* Custom Checkbox */
.custom-checkbox-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.custom-checkbox {
  appearance: none;
  width: 20px;
  height: 20px;
  border: 2px solid #cbd5e1;
  border-radius: 5px;
  outline: none;
  cursor: pointer;
  position: relative;
  transition: var(--transition);
  background: #ffffff;
}

.custom-checkbox:checked {
  background-color: var(--brand-blue);
  border-color: var(--brand-blue);
}

.custom-checkbox:checked::after {
  content: '';
  position: absolute;
  left: 6px;
  top: 2px;
  width: 5px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Stage Actions */
.stage-action-container {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-action-accept {
  background: var(--success-light);
  border: 1px solid #a7f3d0;
  color: var(--success-text);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-action-accept:hover {
  background: #d1fae5;
  border-color: #6ee7b7;
}

.btn-action-stall {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.775rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-action-stall:hover {
  background: #fee2e2;
  border-color: #fca5a5;
  color: var(--danger-text);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.775rem;
  font-weight: 600;
}

.badge-qualified {
  background: var(--success-light);
  color: var(--success-text);
  border: 1px solid #a7f3d0;
}

.badge-stalled {
  background: var(--stalled-light);
  color: var(--stalled-text);
  border: 1px solid #cbd5e1;
}

.badge-waiting {
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.btn-delete-row {
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.4;
  font-size: 0.95rem;
  transition: opacity 0.2s;
  padding: 4px;
}

.btn-delete-row:hover {
  opacity: 1;
}

/* Empty State */
.empty-state {
  padding: 48px 24px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-icon {
  font-size: 2.2rem;
  margin-bottom: 4px;
}

.empty-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.empty-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  max-width: 400px;
}

/* --- Mobile Optimized Lead Cards View --- */
.mobile-leads-list {
  display: none; /* Desktop hides this */
}

.mobile-lead-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 14px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mobile-lead-card:active {
  background: #fafafa;
}

.mobile-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mobile-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.mobile-lead-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mobile-lead-name.is-red {
  color: #dc2626;
}

.mobile-header-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.mobile-card-url-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.mobile-url-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: var(--radius-sm);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--brand-blue);
  text-decoration: none;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-url-chip:hover {
  background: #dbeafe;
}

.mobile-actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 2px;
}

.mobile-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 0.775rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-color);
  background: #f8fafc;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 42px;
  touch-action: manipulation;
}

.mobile-toggle-btn.is-active-comment {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.mobile-toggle-btn.is-active-conn {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}

.mobile-pipeline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}

/* --- Modals --- */
.modal-overlay, .modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-modal);
  overflow: hidden;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modal-pop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-subtitle {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 20px 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.bulk-config-row {
  display: flex;
  gap: 14px;
  align-items: flex-end;
}

.align-end {
  display: flex;
  align-items: flex-end;
}

.bulk-paste-accordion {
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 12px;
}

.paste-summary {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.paste-assistant-body {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.paste-hint {
  font-size: 0.775rem;
  color: var(--text-secondary);
}

.bulk-rows-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding-right: 4px;
}

.bulk-row-item {
  display: grid;
  grid-template-columns: 36px 1.5fr 1fr;
  gap: 10px;
  align-items: center;
  background: #fafafa;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
}

.bulk-row-index {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #fafafa;
}

/* --- Toast Notifications --- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20000;
}

.toast {
  background: #1e293b;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideIn 0.25s ease-out;
}

.toast-success { background: #065f46; }
.toast-error { background: #991b1b; }

@keyframes slideIn {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ========================================================
   HIGH OPTIMIZATION FOR MOBILE PHONES (Responsive Design)
   ======================================================== */
@media (max-width: 900px) {
  .target-card {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .content-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 768px) {
  body {
    padding: 12px 10px;
  }

  .app-container {
    gap: 14px;
  }

  /* Header mobile stack */
  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding-bottom: 12px;
  }

  .header-left {
    align-items: flex-start;
  }

  .brand-logo-img {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .brand-title {
    font-size: 1.25rem;
  }

  .brand-subtitle {
    font-size: 0.8rem;
  }

  .header-right {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    width: 100%;
  }

  .user-email-chip {
    max-width: 140px;
    font-size: 0.75rem;
  }

  /* Target Card Mobile */
  .target-card {
    grid-template-columns: 1fr;
    padding: 16px;
    gap: 14px;
  }

  .target-input-row {
    flex-direction: row;
    gap: 8px;
  }

  .target-input {
    flex: 1;
    font-size: 16px; /* Prevents auto zoom */
  }

  /* Metrics 2x2 Grid */
  .metrics-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .metric-card {
    padding: 12px;
    gap: 10px;
  }

  .metric-icon {
    width: 38px;
    height: 38px;
  }

  .metric-val {
    font-size: 1.25rem;
  }

  .metric-label {
    font-size: 0.7rem;
  }

  /* Lead Entry Card */
  .entry-card {
    padding: 16px;
  }

  .lead-form input {
    font-size: 16px; /* Prevents auto zoom */
  }

  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  .date-col {
    width: 100%;
  }

  .form-footer {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .form-footer-left {
    justify-content: space-between;
    width: 100%;
  }

  .add-lead-btn {
    width: 100%;
    min-height: 44px;
    justify-content: center;
  }

  /* Switch Desktop Table to Touch Mobile Cards */
  .desktop-table-view {
    display: none !important;
  }

  .mobile-leads-list {
    display: flex !important;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
  }

  /* Tabs horizontal touch scroll */
  .view-tabs {
    gap: 6px;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
  }
  .view-tabs::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    padding: 6px 12px;
    font-size: 0.8rem;
  }

  /* Filter & search mobile layout */
  .table-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .date-filter-group {
    width: 100%;
    justify-content: space-between;
  }

  .filter-date-input {
    flex: 1;
    font-size: 16px;
  }

  .search-box {
    max-width: 100%;
    width: 100%;
  }

  .search-box input {
    font-size: 16px;
  }

  .export-group {
    width: 100%;
    justify-content: flex-end;
  }

  /* Bulk modal on mobile */
  .modal-overlay {
    padding: 10px;
  }

  .modal-card {
    max-height: 92vh;
    border-radius: 16px;
  }

  .modal-header, .modal-body, .modal-footer {
    padding: 14px 16px;
  }

  .bulk-config-row {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .bulk-row-item {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}

@media (max-width: 480px) {
  body {
    padding: 8px 6px;
  }

  .auth-gate-card {
    padding: 24px 18px;
    border-radius: 16px;
  }

  .otp-main-input {
    font-size: 1.5rem;
    letter-spacing: 8px;
  }

  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    font-size: 0.8rem;
    padding: 8px 12px;
  }
}
