:root {
  --green-dark:  #063c19;
  --green-mid:   #316142;
  --green-light: #f3f8f0;
  --green-pale:  #e8f2e4;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  background: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  -webkit-text-size-adjust: 100%;
}

/* ── Nav ───────────────────────────────────────────────────────────────── */
.nav {
  background: var(--green-dark);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  height: 56px;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 50;
}
.nav-logo {
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: -0.01em;
  color: #fff;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-logo svg { opacity: 0.9; }
.nav-links {
  display: flex;
  gap: 0.125rem;
  flex: 1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-links::-webkit-scrollbar { display: none; }
.nav-link {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 0.8125rem;
  padding: 0.375rem 0.6rem;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-link:hover  { background: rgba(255,255,255,0.1); color: #fff; }
.nav-link.active { background: rgba(255,255,255,0.15); color: #fff; font-weight: 500; }
.nav-logout {
  background: none;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.7);
  font-size: 0.8125rem;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.nav-logout:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ── Page container ────────────────────────────────────────────────────── */
.page {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.25rem 1rem;
}

/* ── Stat cards ────────────────────────────────────────────────────────── */
.stat-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1rem 1.25rem;
}
.stat-label {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: #0f172a;
  line-height: 1;
}
.stat-sub {
  font-size: 0.75rem;
  color: #94a3b8;
  margin-top: 0.3rem;
}
.stat-card.highlight { border-color: var(--green-mid); }
.stat-card.highlight .stat-value { color: var(--green-mid); }

/* ── Status badges ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: 99px;
  white-space: nowrap;
}
.badge::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-called         { background: #f1f5f9; color: #475569; }
.badge-sms_sent       { background: #fef3c7; color: #92400e; }
.badge-form_submitted { background: var(--green-pale); color: var(--green-dark); }

/* ── Range pills ───────────────────────────────────────────────────────── */
.range-pills {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}
.range-pill {
  background: none;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.3rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}
.range-pill:hover   { border-color: var(--green-mid); color: var(--green-mid); }
.range-pill.active  { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }

/* ── Chart containers ──────────────────────────────────────────────────── */
.chart-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
}
.chart-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 0.875rem;
}

/* ── Table ─────────────────────────────────────────────────────────────── */
.leads-table { width: 100%; border-collapse: collapse; }
.leads-table th {
  text-align: left;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.65rem 0.875rem;
  border-bottom: 1px solid #e2e8f0;
  background: #f8fafc;
  white-space: nowrap;
}
.leads-table td {
  padding: 0.75rem 0.875rem;
  font-size: 0.875rem;
  color: #334155;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}
.leads-table tr { cursor: pointer; transition: background 0.1s; }
.leads-table tbody tr:hover td { background: #f8fafc; }
.leads-table tr.expanded td { background: var(--green-light); }

/* Hide less-important columns on tablet */
@media (max-width: 900px) {
  .col-hide-tablet { display: none !important; }
}
/* On mobile show only essentials */
@media (max-width: 580px) {
  .col-hide-mobile { display: none !important; }
}

/* ── Expandable detail drawer ──────────────────────────────────────────── */
.detail-drawer { background: var(--green-light); border-bottom: 1px solid #e2e8f0; }
.detail-drawer td { padding: 1rem 1rem !important; cursor: default; }
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.65rem;
  margin-bottom: 0.875rem;
}
.detail-field label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.2rem;
}
.detail-field span { font-size: 0.875rem; color: #1e293b; word-break: break-word; }

/* Timeline */
.timeline {
  display: flex;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.4rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tl-step { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; }
.tl-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #e2e8f0;
  border: 2px solid #e2e8f0;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.tl-dot.done { background: var(--green-mid); border-color: var(--green-mid); }
.tl-dot svg  { width: 12px; height: 12px; color: #fff; }
.tl-label    { font-size: 0.65rem; font-weight: 600; color: #64748b; white-space: nowrap; }
.tl-time     { font-size: 0.65rem; color: #94a3b8; white-space: nowrap; }
.tl-line     { flex: 1; height: 2px; background: #e2e8f0; min-width: 16px; }
.tl-line.done{ background: var(--green-mid); }

/* Call history */
.call-item {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.75rem 0.875rem;
  margin-bottom: 0.5rem;
}
.call-meta {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0.4rem;
}
.call-meta span { font-size: 0.8rem; color: #475569; }
.call-transcript {
  font-size: 0.8rem;
  color: #475569;
  white-space: pre-wrap;
  max-height: 120px;
  overflow-y: auto;
  background: #f8fafc;
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  margin-top: 0.5rem;
  line-height: 1.5;
}

/* ── Filter tabs ───────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 0.25rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  flex-shrink: 0;
}
.filter-tabs::-webkit-scrollbar { display: none; }
.filter-tab {
  background: none;
  border: 1px solid #e2e8f0;
  color: #64748b;
  font-size: 0.8125rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.filter-tab:hover  { border-color: var(--green-mid); color: var(--green-mid); }
.filter-tab.active { background: var(--green-dark); border-color: var(--green-dark); color: #fff; }

/* ── Toolbar ───────────────────────────────────────────────────────────── */
.toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
@media (max-width: 580px) {
  .toolbar { flex-direction: column; align-items: stretch; }
  .filter-tabs { width: 100%; }
}

/* ── Search input ──────────────────────────────────────────────────────── */
.search-input {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  outline: none;
  width: 100%;
  max-width: 280px;
  transition: border-color 0.15s;
}
.search-input:focus { border-color: var(--green-mid); }
@media (max-width: 580px) {
  .search-input { max-width: 100%; }
}

/* ── Pagination ────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.875rem;
  border-top: 1px solid #f1f5f9;
  font-size: 0.8rem;
  color: #64748b;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.pag-btns { display: flex; gap: 0.25rem; }
.pag-btn {
  border: 1px solid #e2e8f0;
  background: none;
  border-radius: 6px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.8rem;
  color: #475569;
  transition: all 0.15s;
}
.pag-btn:hover:not(:disabled) { border-color: #316142; color: #316142; }
.pag-btn:disabled { opacity: 0.4; cursor: default; }

/* ── Login page ────────────────────────────────────────────────────────── */
.login-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}

/* ── Live indicator ────────────────────────────────────────────────────── */
.live-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse 2s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Misc ──────────────────────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 2.5rem 1rem;
  color: #94a3b8;
  font-size: 0.875rem;
}

/* ── Page headers ──────────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.65rem;
}
.page-title { font-size: 1.125rem; font-weight: 700; color: #0f172a; margin: 0; }

/* ── Table card ────────────────────────────────────────────────────────── */
.table-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
