:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --panel-muted: #eef2f7;
  --line: #dde4ee;
  --line-strong: #cad5e3;
  --text: #172133;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --success: #198754;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --neutral-soft: #e5e7eb;
  --shadow: 0 14px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 24px rgba(15, 23, 42, 0.06);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 14px;
  --heading: Inter, "Segoe UI", sans-serif;
  --body: Inter, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--body);
  color: var(--text);
  background: linear-gradient(180deg, #f8fafc 0%, #f1f5f9 100%);
}

.backdrop {
  display: none;
}

.shell {
  width: min(1440px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.5rem 0 8rem;
}

.hero,
.panel,
.stat,
.domain-card,
.profile-card,
.run-card,
.workflow-card,
.profile-section,
.queue-card,
.empty-state-card,
.crm-list-panel,
.crm-drawer,
.bottom-actions {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
}

.hero,
.panel,
.bottom-actions {
  border-radius: var(--radius-lg);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
  gap: 1.5rem;
  padding: 1.75rem;
}

.hero h1,
.panel h2,
.card-title,
.bottom-actions h2 {
  margin: 0;
  font-family: var(--heading);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.hero h1 {
  font-size: clamp(2.3rem, 4.6vw, 4.4rem);
  line-height: 0.94;
  max-width: 11ch;
}

.lede,
.workflow-card p,
.workflow-note,
.mail-status-message,
.desktop-update-message {
  color: var(--muted);
  line-height: 1.65;
}

.hero-actions,
.review-toolbar,
.review-filter-group,
.run-card-actions,
.review-actions,
.bottom-actions-buttons,
.desktop-update-actions,
.choice-grid,
.pill-row,
.lead-form-preview,
.crm-active-filters,
.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.button-link {
  text-decoration: none;
}

.eyebrow {
  margin: 0 0 0.4rem;
  color: var(--accent-strong);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  font-weight: 700;
}

.hero-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  align-content: start;
}

.stat,
.domain-card,
.profile-card,
.run-card,
.workflow-card,
.profile-section,
.queue-card,
.empty-state-card {
  border-radius: var(--radius-md);
  padding: 1rem;
}

.stat strong {
  display: block;
  margin-top: 0.5rem;
  font-size: 2rem;
  line-height: 1;
}

.stat-label,
.muted,
.run-metric span,
.detail-label,
.lead-metric span,
.drawer-keymetric span,
.crm-filterbar label,
.run-form label,
.profile-card label,
.draft-editor label {
  color: var(--muted);
}

.panel {
  margin-top: 1.25rem;
  padding: 1.35rem;
}

.system-notice {
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  border-color: #fde68a;
  background: #fffbeb;
  color: #92400e;
  font-weight: 600;
}

.workflow-panel,
.workflow-grid,
.domain-grid,
.profiles-grid,
.runs-grid,
.inbound-grid,
.crm-search-panel,
.review-pane,
.review-grid,
.sequence-grid,
.input-list,
.rule-list,
.profile-card form,
.profile-form,
.draft-editor,
.mail-status-panel,
.desktop-update-panel,
.desktop-update-layout {
  display: grid;
  gap: 1rem;
}

.workflow-grid,
.domain-grid,
.runs-grid,
.inbound-grid {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.profiles-grid {
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
}

.workflow-card h3,
.domain-card h3,
.profile-card h3,
.run-card h3,
.empty-state-card h3,
.crm-list-head h3,
.drawer-empty h3 {
  margin: 0 0 0.45rem;
  font-size: 1.05rem;
}

.workflow-step {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-bottom: 0.75rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 700;
}

.workflow-note,
#gravity-config {
  padding: 0.95rem 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.section-head-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.review-summary,
.review-helper,
.bottom-actions-copy .muted,
.mail-status-message,
.desktop-update-message {
  margin: 0.3rem 0 0;
}

.run-card-head,
.crm-list-head,
.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.run-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.run-metric {
  padding: 0.8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel-soft);
}

.run-metric strong {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.1rem;
}

.pill,
.status-pill,
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 999px;
  padding: 0.34rem 0.7rem;
  font-size: 0.78rem;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.pill {
  background: var(--panel-muted);
  color: var(--text);
  border-color: var(--line);
}

.status-pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-pill[data-tone="muted"] {
  background: #eef2f7;
  color: var(--muted);
}

.status-pill[data-tone="success"] {
  background: var(--success-soft);
  color: var(--success);
}

.status-pill[data-tone="danger"] {
  background: var(--danger-soft);
  color: var(--danger);
}

.badge-brand {
  background: #ede9fe;
  color: #6d28d9;
}

.badge-source {
  background: #eff6ff;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.badge-premium {
  background: #dcfce7;
  color: #166534;
  border-color: #bbf7d0;
}

.badge-low-budget {
  background: #f3f4f6;
  color: #4b5563;
  border-color: #d1d5db;
}

.badge-full-package {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #bfdbfe;
}

.badge-partial-bundle {
  background: #eff6ff;
  color: #2563eb;
  border-color: #93c5fd;
  border-style: dashed;
}

.badge-unknown {
  background: #fef3c7;
  color: #b45309;
  border-color: #fcd34d;
}

.badge-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  font-size: 0.78rem;
}

button,
select,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.primary-button,
.ghost-button,
.inline-button,
.danger-button {
  border-radius: 12px;
  padding: 0.78rem 1rem;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}

.primary-button {
  background: var(--accent);
  color: white;
  font-weight: 700;
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.2);
}

.inline-button,
.ghost-button {
  background: white;
  color: var(--text);
  border-color: var(--line-strong);
}

.danger-button {
  background: #fff1f2;
  color: var(--danger);
  border-color: #fecdd3;
}

.primary-button:hover,
.inline-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.run-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  align-items: end;
}

.run-form label,
.profile-card label,
.crm-filterbar label,
.draft-editor label {
  display: grid;
  gap: 0.45rem;
  font-size: 0.92rem;
}

select,
textarea,
input {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  padding: 0.78rem 0.9rem;
}

select:focus,
textarea:focus,
input:focus,
button:focus-visible {
  outline: none;
  border-color: #93c5fd;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.profile-section,
.profile-card,
.run-card,
.queue-card,
.empty-state-card,
.crm-list-panel,
.crm-drawer {
  overflow: hidden;
}

.profile-section {
  background: var(--panel-soft);
}

.inline-grid {
  display: grid;
  gap: 0.75rem;
}

.inline-grid.two-columns {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.choice-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 0.48rem 0.82rem;
  background: white;
  color: var(--text);
}

.choice-chip input {
  width: auto;
  margin: 0;
}

.rule-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(80px, 120px) 2fr;
  gap: 0.75rem;
  padding: 0.7rem 0.8rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: white;
  color: var(--muted);
  font-size: 0.88rem;
}

.job-status {
  color: var(--accent-strong);
  font-size: 0.92rem;
  font-weight: 600;
}

.bottom-actions {
  position: fixed;
  left: 50%;
  bottom: 1rem;
  transform: translateX(-50%);
  z-index: 10;
  width: min(1440px, calc(100% - 2rem));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.2rem;
}

.bottom-actions.is-hidden {
  display: none;
}

.bottom-actions-copy h2 {
  font-size: 1.1rem;
}

.bottom-actions-buttons {
  justify-content: flex-end;
}

.queue-card + .queue-card {
  margin-top: 0.75rem;
}

#live-inbound-queue,
#historical-review-queue,
#dedupe-queue {
  margin-top: 0.9rem;
}

.draft-preview {
  margin-top: 0.9rem;
  padding: 0.95rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel-soft);
  line-height: 1.65;
}

.draft-preview p {
  margin: 0.5rem 0 0;
}

.delivery-error {
  margin: 0.75rem 0 0;
  color: var(--danger);
  line-height: 1.5;
}

.score-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-left: 0.35rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: white;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1;
  cursor: help;
}

.score-help:hover {
  color: var(--accent-strong);
  border-color: #93c5fd;
}

.signal-list {
  margin: 0.75rem 0 0;
  padding-left: 1.15rem;
}

.signal-list li {
  margin-bottom: 0.5rem;
  line-height: 1.55;
}

.crm-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(380px, 0.95fr);
  gap: 1rem;
  align-items: start;
}

.crm-search-panel {
  margin-bottom: 1rem;
}

.crm-search-workspace {
  margin-top: 1rem;
}

.crm-list-panel,
.crm-drawer {
  border-radius: var(--radius-md);
}

.crm-list-panel {
  min-height: 720px;
}

.crm-drawer {
  position: sticky;
  top: 1rem;
  padding: 1rem;
  min-height: 720px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-gutter: stable;
  padding-bottom: 7rem;
}

.crm-drawer:not(.is-open) {
  display: grid;
  place-items: center;
}

.crm-filterbar {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(10px);
}

.crm-filter-search {
  margin-bottom: 0.85rem;
}

.crm-filter-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.crm-active-filters {
  margin-top: 0.85rem;
}

.crm-list-head {
  padding: 1rem 1rem 0;
}

.crm-list-footer {
  padding: 0 1rem 1rem;
}

.lead-list {
  display: grid;
  gap: 0.85rem;
  padding: 1rem;
}

.lead-list-card {
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  padding: 1rem;
  box-shadow: none;
}

.crm-results-list {
  display: grid;
  gap: 0.85rem;
}

.lead-list-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.scheduled-outreach-drawer {
  margin-top: 0;
}

#scheduled-outreach-panel .crm-workspace {
  margin-top: 1rem;
}

#scheduled-outreach-panel .crm-list-panel {
  min-height: 720px;
}

#scheduled-outreach-panel .crm-results-list {
  padding: 1rem;
}

.lead-list-card:hover,
.lead-list-card.is-selected {
  border-color: #93c5fd;
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.12);
}

.lead-list-top {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.lead-list-name {
  display: block;
  font-size: 1.05rem;
  color: var(--text);
}

.lead-list-subtitle {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.lead-list-date {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.lead-list-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 0.9rem;
}

.lead-metric {
  display: inline-flex;
  flex-direction: column;
  gap: 0.12rem;
  padding: 0.7rem 0.8rem;
  border-radius: 12px;
  background: var(--panel-soft);
  min-width: 110px;
}

.lead-metric strong,
.drawer-keymetric strong {
  font-size: 1rem;
  color: var(--text);
}

.lead-list-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.lead-list-summary,
.detail-copy,
.drawer-empty p {
  margin: 0.9rem 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.detail-copy {
  white-space: pre-wrap;
}

.mail-thread-list {
  display: grid;
  gap: 0.85rem;
}

.mail-thread-card {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 0.95rem 1rem;
}

.mail-thread-head {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  align-items: flex-start;
}

.mail-thread-body {
  margin-top: 0.75rem;
  color: var(--text);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}

.drawer-header,
.drawer-keyline,
.detail-section + .detail-section {
  margin-top: 1rem;
}

.drawer-header {
  position: sticky;
  top: -1rem;
  z-index: 3;
  margin: -1rem -1rem 0;
  padding: 1rem 1rem 0.9rem;
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.drawer-header h3 {
  margin: 0;
  font-size: 1.35rem;
}

.drawer-keyline {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.75rem;
  padding-top: 0.25rem;
}

.drawer-keymetric {
  padding: 0.9rem;
  border-radius: 14px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
}

.drawer-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  padding-bottom: 1rem;
  margin-bottom: 0.35rem;
  border-bottom: 1px solid var(--line);
}

.detail-section {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.detail-section h4 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.detail-item {
  padding: 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
}

.detail-label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.28rem;
}

.detail-value {
  color: var(--text);
  line-height: 1.45;
  word-break: break-word;
}

.detail-value.is-strong {
  font-weight: 700;
  font-size: 1rem;
}

.drawer-empty {
  text-align: center;
  max-width: 24rem;
}

.review-toolbar {
  justify-content: flex-end;
}

.review-filter-group {
  margin-top: 0.85rem;
}

.review-actions {
  margin-top: 1rem;
}

a.link {
  color: var(--accent-strong);
}

.is-auth-hidden {
  display: none !important;
}

.auth-toolbar,
.auth-gate {
  margin-bottom: 1.25rem;
}

.auth-actions {
  align-items: center;
}

.auth-gate-copy {
  display: grid;
  gap: 1rem;
}

.auth-admin-grid {
  display: grid;
  grid-template-columns: minmax(18rem, 26rem) minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.auth-user-form,
.auth-user-list {
  display: grid;
  gap: 0.85rem;
}

.auth-user-items {
  display: grid;
  gap: 0.75rem;
}

.auth-user-item {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 0.9rem 1rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  background: rgba(255,255,255,0.7);
}

@media (max-width: 1180px) {
  .crm-workspace {
    grid-template-columns: 1fr;
  }

  .crm-drawer {
    position: static;
    min-height: 0;
    max-height: none;
    overflow: visible;
    padding-bottom: 1rem;
  }

  .crm-filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .run-metric-grid,
  .drawer-keyline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .drawer-header {
    position: static;
    top: auto;
    margin: 0;
    padding: 0 0 1rem;
    background: transparent;
    backdrop-filter: none;
  }
}

@media (max-width: 820px) {
  .shell {
    width: min(100%, calc(100% - 1rem));
    padding-bottom: 10rem;
  }

  .hero,
  .section-head,
  .bottom-actions {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .hero-panel,
  .auth-admin-grid,
  .crm-filter-grid,
  .run-form,
  .workflow-grid,
  .domain-grid,
  .inbound-grid,
  .runs-grid,
  .profiles-grid,
  .run-metric-grid,
  .drawer-keyline,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .lead-list-top,
  .run-card-head,
  .drawer-header,
  .crm-list-head {
    flex-direction: column;
  }

  .bottom-actions {
    width: calc(100% - 1rem);
    left: 0.5rem;
    transform: none;
  }

  .bottom-actions-buttons {
    width: 100%;
  }

  .bottom-actions-buttons button,
  .review-actions button,
  .run-card-actions button {
    flex: 1 1 100%;
  }
}
