:root {
  color-scheme: light;
  font-family: Inter, system-ui, sans-serif;
  
  /* Brand Colors */
  --brand-blue: #234E8C;
  --brand-blue-600: #2563EB;
  --ink-900: #0F172A;
  --ink-700: #334155;
  --panel: #FFFFFF;
  --border: #E5E7EB;
  
  /* Legacy aliases for compatibility */
  --bg: #f5f7fb;
  --text: var(--ink-900);
  --muted: #6b7280;
  --accent: var(--brand-blue-600);
  --accent-soft: rgba(37, 99, 235, 0.1);
  --danger: #dc2626;
  
  /* Radius & Shadow */
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow: 0 8px 24px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  min-height: 100%;
}

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

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.brand {
  font-weight: 600;
  font-size: 1.1rem;
}

.top-links {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.top-links a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}

.top-links a:hover,
.top-links a:focus {
  color: var(--text);
  text-decoration: underline;
}

.project-select select {
  padding: 0.35rem 0.75rem;
  font-size: 0.95rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--bg);
}

.status-pill {
  background: var(--accent-soft);
  color: var(--accent);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
}

.toolbar .btn {
  font-size: 0.9rem;
}

.toolbar-spacer {
  flex: 1;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.9rem;
}

.top-select {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.9rem;
}

.top-select select {
  padding: 0.25rem 0.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
  background: var(--panel);
}

.btn {
  border: 1px solid transparent;
  border-radius: 0.65rem;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  background: var(--panel);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(31, 41, 55, 0.12);
}

.btn.primary {
  background: var(--accent);
  color: #fff;
}

.btn.secondary {
  border-color: var(--border);
  color: var(--text);
}

.btn.close {
  background: transparent;
  border: none;
  font-size: 1.2rem;
  line-height: 1;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 65%) minmax(320px, 35%);
  gap: 1rem;
  padding: 1rem 1.5rem 2rem;
  flex: 1;
}
@media (max-width: 1280px) {
  .layout {
    grid-template-columns: minmax(0, 60%) minmax(280px, 40%);
  }
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .drawer {
    position: relative;
    top: auto;
    max-height: none;
  }
  .drawer-header {
    flex-direction: column;
    align-items: stretch;
  }
  .drawer-header-actions {
    flex-direction: row;
    justify-content: space-between;
    width: 100%;
  }
}


.table-panel {
  background: var(--panel);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  text-align: left;
  padding: 0.75rem 0.75rem 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

tbody td {
  padding: 0.65rem 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.95rem;
}

#leadsTable td.col-nace {
  max-width: 240px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#leadsTable td.col-rank {
  white-space: nowrap;
}

#leadsTable td.col-rank.adjusted {
  color: var(--accent);
  font-weight: 600;
}

.rank-primary {
  font-weight: 600;
}

.rank-secondary {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.05);
  cursor: pointer;
}

#leadsTable th[data-col="contacts_count"],
#leadsTable td.col-contacts {
  text-align: center;
  width: 6rem;
}

#leadsTable td.col-contacts .badge {
  margin-left: 0.35rem;
}

#leadsTable th[data-col="last_enriched_date"],
#leadsTable td.col-last-enriched,
#leadsTable th[data-col="last_contact_date"],
#leadsTable td.col-last-contact {
  text-align: center;
  white-space: nowrap;
  width: 7.5rem;
  color: var(--muted);
  font-size: 0.9rem;
}

.row-high {
  background: rgba(16, 185, 129, 0.08);
}

.row-nurture {
  background: rgba(234, 179, 8, 0.08);
}

.row-archive {
  background: rgba(148, 163, 184, 0.15);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.warm {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}


.badge.manual {
  background: rgba(99, 102, 241, 0.15);
  color: #4338ca;
  margin-left: 0.4rem;
}

.muted-note {
  color: var(--muted);
  font-size: 0.85rem;
}

.muted {
  color: var(--muted);
}

.summary-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.35rem;
}

.summary-row strong {
  min-width: 80px;
}

.summary-row-revenue {
  align-items: baseline;
}

.summary-muted {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: calc(0.5rem + 0.2rem);
}

.badge.enrich {
  background: rgba(234, 179, 8, 0.1);
  color: #b45309;
  margin-left: 0.35rem;
}

.badge.source {
  background: rgba(59, 130, 246, 0.15);
  color: #1d4ed8;
  text-transform: uppercase;
}

.contact-meta {
  margin-top: 0.25rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.drawer {
  position: sticky;
  top: 1rem;
  align-self: start;
  background: var(--panel);
  border-radius: 1rem;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  width: 100%;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}


.drawer-title-block {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.drawer-title-block h2 {
  margin: 0;
  font-size: 1.35rem;
}

.drawer-meta-primary,
.drawer-meta-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.9rem;
}

.drawer-meta-secondary {
  color: var(--muted);
  font-size: 0.85rem;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.meta-item strong {
  font-weight: 600;
}

.meta-item.muted strong {
  color: var(--muted);
}

.meta-sub {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 400;
}

.score-summary {
  font-size: 0.95rem;
}

.rank-meta {
  font-size: 1rem;
}

.drawer-header-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: flex-end;
}

.drawer.hidden {
  display: none;
}

.drawer-close {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  border: none;
  background: transparent;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.drawer-content h2 {
  margin: 0 0 0.5rem;
}

.drawer-section {
  margin-bottom: 1.25rem;
}

.drawer-section h3 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.score-control {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 180px;
}

.score-select {
  padding: 0.35rem 0.6rem;
  border-radius: 0.65rem;
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 0.9rem;
}

.score-slider {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.score-slider input[type="range"] {
  flex: 1;
}

.score-adjust-label {
  font-size: 0.85rem;
  color: var(--muted);
  min-width: 120px;
  text-align: right;
}

.btn.ghost {
  background: transparent;
  border: none;
  color: var(--accent);
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
}

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

.description-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

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

.contact-dropdown {
  margin-top: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  background: rgba(249, 250, 251, 0.85);
}

.contact-card {
  background: rgba(37, 99, 235, 0.05);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.contact-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.contact-title {
  font-size: 0.85rem;
  color: var(--muted);
}

.contact-socials {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.25rem;
}

.social-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.7rem;
  text-decoration: none;
}

.contact-card a {
  color: var(--accent);
  text-decoration: none;
}

.contact-card a:hover {
  text-decoration: underline;
}

.signals-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 260px;
  overflow-y: auto;
}

.signal-item {
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  background: rgba(37, 99, 235, 0.04);
}

.signal-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.signal-description {
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--text);
}

.signal-meta {
  margin-top: 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.score-list,
.warm-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.contact-card + .contact-card {
  margin-top: 0;
}

.drawer-edit {
  border-top: 1px solid var(--border);
  padding-top: 1.25rem;
}

.drawer-edit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

.drawer-subsection {
  margin-bottom: 1.25rem;
}

.drawer-actions,
.queue-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.75rem;
}

.form-grid.vertical {
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.contact-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.5rem;
  font-size: 0.85rem;
}

.contact-table th,
.contact-table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: left;
}

.contact-table button {
  border: none;
  background: transparent;
  color: var(--danger);
  cursor: pointer;
}

.signals-box {
  background: rgba(37, 99, 235, 0.06);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 0.75rem;
  min-height: 80px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.quick-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem 0.6rem;
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.8rem;
}

.fit-notes {
  background: #0f172a;
  color: #e2e8f0;
  padding: 0.75rem;
  border-radius: 0.75rem;
  font-size: 0.85rem;
  overflow-x: auto;
}

.warm-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.warm-list li {
  padding: 0.4rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.9rem;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
}

.checklist li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  font-size: 0.9rem;
}

.footer {
  padding: 0.75rem 1.5rem 1.5rem;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.footer-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.footer-link:hover,
.footer-link:focus {
  text-decoration: underline;
}

.notice {
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.hidden {
  display: none !important;
}

.panel[hidden] {
  display: none !important;
}

.sidebar-tab {
  border-left: 4px solid transparent;
  color: #475569;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.sidebar-tab.active {
  background: #eff6ff;
  border-left-color: #2563eb;
  color: #1d4ed8;
}

.sidebar-tab.active span.flex-1 > span:first-child {
  color: #1d4ed8;
}

.view-chip {
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  background: transparent;
  transition: box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.view-chip.active {
  background: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.view-chip:not(.active):hover {
  background: #f8fafc;
}

.assistant-chip {
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem;
  padding: 0.375rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  background: #ffffff;
  transition: box-shadow 0.2s ease, background 0.2s ease, color 0.2s ease;
}

.assistant-chip.active {
  color: #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.assistant-chip:not(.active):hover {
  background: #f8fafc;
}

.view-section {
  display: block;
}

.panel {
  display: block;
}

.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal-content {
  background: var(--panel);
  padding: 1.25rem;
  border-radius: 0.9rem;
  width: min(520px, 90vw);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  max-height: 60vh;
  overflow-y: auto;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
}

.form-grid input,
.form-grid select {
  padding: 0.5rem;
  border-radius: 0.6rem;
  border: 1px solid var(--border);
  font-size: 0.9rem;
}

.modal-footer {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.modal-spacer {
  flex: 1;
}

.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  backdrop-filter: blur(2px);
  z-index: 15;
}

.toast {
  margin-left: auto;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.15);
  color: #0f766e;
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .drawer {
    position: fixed;
    inset: auto 0 0 0;
    max-height: 70vh;
    border-radius: 1rem 1rem 0 0;
  }

  .top-bar {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .status-pill {
    order: 3;
  }

  .toolbar {
    gap: 0.5rem;
  }

  .toolbar .btn,
  .top-select select {
    width: 100%;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  thead th,
  tbody td {
    padding: 0.5rem;
  }

  .btn {
    width: 100%;
  }
}

.manual-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

/* Deals classification board */
.deals-page {
  background: transparent;
}

.deals-header {
  margin-bottom: 1.5rem;
}

.deals-board {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
}

.deals-column {
  border-radius: 18px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 480px;
  transition: box-shadow 0.2s ease;
}

.deals-column[data-stage="high"] {
  background: #f7fdf7;
}

.deals-column[data-stage="nurture"] {
  background: #fffef6;
}

.deals-column[data-stage="archive"] {
  background: #f6f9ff;
}

.deals-column.is-dragover {
  box-shadow: inset 0 0 0 3px rgba(37, 99, 235, 0.2);
}

.deals-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.65rem 0.85rem;
  border-radius: 14px;
  font-weight: 600;
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.deals-column-header--high {
  background: rgba(34, 197, 94, 0.18);
  color: #166534;
}

.deals-column-header--nurture {
  background: rgba(250, 204, 21, 0.18);
  color: #92400e;
}

.deals-column-header--archive {
  background: rgba(59, 130, 246, 0.18);
  color: #1d4ed8;
}

.deals-count {
  background: rgba(255, 255, 255, 0.85);
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.deals-column-body {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.deals-column-explainer {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: #475569;
}

.deals-card {
  background: rgba(255, 255, 255, 0.94);
  border-radius: 14px;
  padding: 1rem 1.1rem;
  box-shadow: 0 18px 26px -24px rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.28);
  cursor: grab;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.deals-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 34px -26px rgba(15, 23, 42, 0.7);
  border-color: rgba(59, 130, 246, 0.25);
}

.deals-card:active {
  cursor: grabbing;
}

.deals-card.is-dragging {
  opacity: 0.6;
  box-shadow: none;
}

.deals-card__title {
  font-weight: 600;
  font-size: 1rem;
  color: #0f172a;
  margin-bottom: 0.55rem;
}

.deals-card__meta {
  display: grid;
  gap: 0.45rem;
  font-size: 0.85rem;
}

.deals-card__meta div {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.deals-card__meta-row {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.8rem;
  color: #1e293b;
}

.deals-card__meta-row span {
  display: inline-flex;
  gap: 4px;
  align-items: baseline;
}

.deals-card__meta dt {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.deals-card__meta dd {
  font-weight: 500;
  color: #1e293b;
}

.deals-empty {
  text-align: center;
  margin-top: 3rem;
}

.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

@media (max-width: 640px) {
  .deals-column {
    min-height: 380px;
  }
}

/* ============================================================================
   Brand & Global Containment
   ============================================================================ */

.page-canvas {
  min-height: 720px;
}

/* White top tabs with subtle border */
.top-tabs {
  background: white;
  border-bottom: 1px solid #e2e8f0;
}

/* Global containment wrapper */
.container-7xl {
  max-width: 80rem; /* 1280px */
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

@media (min-width: 1024px) {
  .container-7xl {
    padding-left: 2rem;
    padding-right: 2rem;
  }
}

.deals-card__emails {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.deals-card__email {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.deals-card__label {
  font-weight: 600;
  color: var(--text-muted, #6b7280);
  margin-right: 4px;
}

.page-canvas {
  min-height: 720px;
}

.top-tabs {
  background: #fff;
}
