/*
 * Dark admin theme, based on the "Free Dark Admin Dashboards" (Dashdark X)
 * Figma file. Only loaded by admin.html (body.theme-dark); client
 * dashboards keep the light style.css look.
 *
 * Tokens from the Figma file:
 *   Neutral 800 #081028  page / sidebar background
 *   Neutral 700 #0A1330  inputs, alternate rows
 *   Neutral 600 #0B1739  cards
 *   Secondary 4 #343B4F  borders
 *   Neutral 400 #AEB9E1  secondary text
 *   Neutral 500 #7E89AC  muted text
 *   Primary     #CB3CFF  (gradient to #7F25FB)
 *   Green 300   #14CA74 on rgba(5,193,104,.2)
 *   Cyan        #00C2FF
 */

body.theme-dark {
  --bg: #081028;
  --surface: #0b1739;
  --surface-2: #0a1330;
  --border: #343b4f;
  --text: #ffffff;
  --text-2: #aeb9e1;
  --muted: #7e89ac;
  --primary: #cb3cff;
  --primary-grad: linear-gradient(166deg, #cb3cff 20%, #7f25fb 68%);
  --green: #14ca74;
  --green-bg: rgba(5, 193, 104, 0.2);
  --red: #ff5a65;
  --red-bg: rgba(255, 90, 101, 0.2);
  --amber: #ffb016;
  --amber-bg: rgba(255, 176, 22, 0.2);
  --cyan: #00c2ff;

  background: var(--bg);
  color: var(--text);
  font-family: 'Mona Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  padding: 0;
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.theme-dark .sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg);
  border-right: 0.6px solid #1c2541;
  box-shadow: 0 8px 28px rgba(1, 5, 17, 0.3);
  padding: 36px 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
}
.theme-dark .sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 40px;
}
.theme-dark .logo-mark {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 7px;
  background: url('/logo.svg') center / contain no-repeat;
}
.theme-dark .sidebar-nav { display: flex; flex-direction: column; gap: 4px; }
.theme-dark .nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 12px;
  border-radius: 6px;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  position: relative;
}
.theme-dark .nav-link svg { width: 14px; height: 14px; flex-shrink: 0; }
.theme-dark .nav-link:hover { background: var(--surface-2); color: var(--text); }
.theme-dark .nav-link.active { color: var(--primary); }
.theme-dark .nav-link.active::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.theme-dark .sidebar-foot {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  padding: 0 12px;
}

/* ---------- Main ---------- */
.theme-dark .container {
  flex: 1;
  min-width: 0; /* let the main column shrink beside the sidebar instead of overflowing */
  max-width: 1120px;
  margin: 0;
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 36px 40px 60px;
}
.theme-dark h1 { font-size: 22px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.theme-dark h2 { font-size: 18px; font-weight: 600; color: var(--text); }
.theme-dark .subtitle { color: var(--text-2); font-size: 12px; }
.theme-dark .page-header { margin-bottom: 28px; }

.theme-dark .card {
  background: var(--surface);
  border: 0.6px solid var(--border);
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 24px;
  box-shadow: 1px 1px 1px rgba(16, 25, 52, 0.4);
}

/* ---------- Stat tiles (Pageviews - Card) ---------- */
.theme-dark .stat-row { gap: 24px; margin-bottom: 28px; }
.theme-dark .stat-tile,
.theme-dark .stat-tile:nth-child(2),
.theme-dark .stat-tile:nth-child(3) {
  background: var(--surface);
  border: 0.6px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  color: var(--text);
  box-shadow: 1px 1px 1px rgba(16, 25, 52, 0.4);
}
.theme-dark .stat-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Work Sans', 'Mona Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  line-height: 14px;
  color: var(--text-2);
  opacity: 1;
}
.theme-dark .stat-label svg { width: 14px; height: 14px; color: var(--primary); }
.theme-dark .stat-tile:nth-child(2) .stat-label svg { color: var(--cyan); }
.theme-dark .stat-tile:nth-child(3) .stat-label svg { color: #7f25fb; }
.theme-dark .stat-line { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.theme-dark .stat-value { font-size: 24px; font-weight: 600; line-height: 32px; margin: 0; }
.theme-dark .stat-pill {
  font-size: 10px;
  font-weight: 500;
  line-height: 14px;
  color: var(--green);
  background: var(--green-bg);
  border: 0.6px solid var(--green-bg);
  border-radius: 2px;
  padding: 2px 4px;
  white-space: nowrap;
}

/* ---------- Leads list as an "Orders Status" table ---------- */
.theme-dark #allLeadsList,
.theme-dark #leadsList {
  background: var(--surface);
  border: 0.6px solid var(--border);
  border-radius: 12px;
  padding: 28px 0 8px;
}
.theme-dark #leadsList { border: none; padding-top: 0; }
.theme-dark #allLeadsList .stat-row { padding: 0 28px; background: transparent; }
.theme-dark #allLeadsList > .stat-row {
  /* Stats sit above the table card, Figma-style. */
  margin: 0 0 28px;
  padding: 0;
  background: transparent;
}
.theme-dark #allLeadsList { background: transparent; border: none; padding: 0; }
.theme-dark .leads-list-header,
.theme-dark .lead,
.theme-dark .call-item,
.theme-dark .text-item,
.theme-dark .kind-empty,
.theme-dark #allLeadsList > .empty-state { background: var(--surface); }

.theme-dark .leads-list-header {
  margin: 0;
  padding: 28px 28px 20px;
  border: 0.6px solid var(--border);
  border-bottom: none;
  border-radius: 12px 12px 0 0;
}
.theme-dark #leadsList .leads-list-header { border: none; padding: 0 0 20px; }
.theme-dark .leads-list-heading { font-size: 18px; font-weight: 600; color: var(--text); }

.theme-dark .lead,
.theme-dark .call-item,
.theme-dark .text-item {
  border: 0.6px solid var(--border);
  border-top: 0.6px solid #1c2541;
  border-left: 3px solid transparent;
  border-radius: 0;
  margin: 0;
  color: var(--text);
}
.theme-dark .lead { border-left-color: var(--primary); }
.theme-dark .call-item { border-left-color: var(--green); }
.theme-dark .call-item.missed { border-left-color: var(--red); }
.theme-dark .text-item { border-left-color: var(--amber); }
.theme-dark #allLeadsList > :nth-child(even of .lead, .call-item, .text-item) { background: var(--surface-2); }
.theme-dark #allLeadsList > :is(.lead, .call-item, .text-item):last-child,
.theme-dark #allLeadsList > .kind-empty:last-child { border-radius: 0 0 12px 12px; }

.theme-dark .lead-row { padding: 14px 28px; background: transparent; }
.theme-dark .lead-row:hover { background: rgba(203, 60, 255, 0.06); }
.theme-dark .lead.expanded .lead-row,
.theme-dark .text-item.expanded .lead-row { background: rgba(203, 60, 255, 0.08); }
.theme-dark .lead-timestamp { color: var(--muted); font-size: 11px; }
.theme-dark .lead-business { color: var(--text); font-size: 15px; font-weight: 600; }
.theme-dark .lead-name { color: var(--text); font-size: 13px; font-weight: 500; }
.theme-dark .lead-name.secondary { color: var(--text-2); font-size: 12px; }
.theme-dark .lead-preview { color: var(--text-2); font-size: 12px; }
.theme-dark .lead-chevron { color: var(--muted); }
.theme-dark .lead-details { padding: 4px 28px 18px; color: var(--text-2); }
.theme-dark .lead-field strong { color: var(--text); }
.theme-dark .call-link { color: var(--cyan); }

/* Status Badge look for type pills and badges */
.theme-dark .type-pill,
.theme-dark .badge {
  font-size: 10px;
  font-weight: 500;
  line-height: 14px;
  border-radius: 2px;
  padding: 2px 6px;
}
.theme-dark .type-pill.form { color: var(--primary); background: rgba(203, 60, 255, 0.18); }
.theme-dark .type-pill.call { color: var(--green); background: var(--green-bg); }
.theme-dark .type-pill.text { color: var(--amber); background: var(--amber-bg); }
.theme-dark .badge { color: var(--cyan); background: rgba(0, 194, 255, 0.15); }
.theme-dark .badge-on { color: var(--green); background: var(--green-bg); }
.theme-dark .badge-off { color: var(--red); background: var(--red-bg); }
.theme-dark .call-item.missed .lead-preview { color: var(--red); }
.theme-dark .textback-note,
.theme-dark .call-item.missed .textback-note { color: var(--amber); }

.theme-dark .call-icon-btn {
  background: var(--surface-2);
  border: 0.6px solid var(--border);
  color: var(--text);
}
.theme-dark .call-audio { filter: invert(0.9) hue-rotate(180deg); opacity: 0.85; }

/* Text threads */
.theme-dark .thread { padding: 4px 28px 18px; }
.theme-dark .bubble.inbound { background: var(--surface-2); border: 0.6px solid var(--border); color: var(--text); }
.theme-dark .bubble.outbound { background: var(--primary-grad); color: #fff; }
.theme-dark .bubble.outbound.auto { background: var(--amber-bg); color: #ffd58a; border: 0.6px dashed var(--amber); }

/* ---------- Filters (Input Text / Master buttons) ---------- */
.theme-dark .business-filter,
.theme-dark .kind-filter {
  background: var(--surface-2);
  border: 0.6px solid var(--surface);
  box-shadow: 1px 1px 0.5px rgba(16, 25, 52, 0.4);
  border-radius: 4px;
  color: var(--text-2);
}
.theme-dark .business-filter { font-size: 12px; padding: 8px 10px; }
.theme-dark .kind-filter button { background: transparent; color: var(--text-2); font-size: 12px; border-radius: 3px; padding: 6px 12px; }
.theme-dark .kind-filter button:hover { filter: none; }
.theme-dark .kind-filter button:hover { background: rgba(255, 255, 255, 0.04); }
.theme-dark .kind-filter button.active { background: var(--primary-grad); color: #fff; box-shadow: none; }

/* ---------- Forms, buttons, misc ---------- */
.theme-dark label { color: var(--text-2); font-size: 12px; }
.theme-dark input,
.theme-dark select,
.theme-dark textarea {
  background: var(--surface-2);
  border: 0.6px solid var(--border);
  color: var(--text);
  border-radius: 4px;
}
.theme-dark input::placeholder,
.theme-dark textarea::placeholder { color: var(--muted); }
.theme-dark input:focus,
.theme-dark select:focus,
.theme-dark textarea:focus { outline: none; border-color: var(--primary); }
.theme-dark input[type="checkbox"] { accent-color: var(--primary); }

.theme-dark button { background: var(--primary-grad); color: #fff; border-radius: 4px; font-size: 12px; }
.theme-dark button:hover { filter: brightness(1.1); background: var(--primary-grad); }
.theme-dark button.secondary { background: var(--surface-2); border: 0.6px solid var(--border); color: var(--text-2); }
.theme-dark button.secondary:hover { color: var(--text); background: #111d44; filter: none; }

.theme-dark .client-list-item,
.theme-dark .site-list-item {
  background: var(--surface-2);
  border: 0.6px solid var(--border);
  border-radius: 8px;
  color: var(--text);
}
.theme-dark .untracked-group { background: var(--surface-2); padding: 14px; box-shadow: none; }
.theme-dark .untracked-site { background: var(--surface); padding: 6px 10px; }
.theme-dark .field-label { font-size: 12px; color: var(--text-2); margin-bottom: 6px; }
.theme-dark .muted { color: var(--muted); font-size: 12px; }
.theme-dark .site-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 6px 6px 0;
  background: var(--surface);
  color: var(--text-2);
  border: 0.6px solid var(--border);
}
.theme-dark .chip-x { padding: 1px 7px; font-size: 11px; }
.theme-dark .link-box { background: var(--bg); border: 0.6px solid var(--border); color: var(--text-2); }
.theme-dark .empty-state { color: var(--muted); padding: 28px; }
.theme-dark .status-banner.success { background: var(--green-bg); color: var(--green); border-color: transparent; }
.theme-dark .status-banner.error { background: var(--red-bg); color: var(--red); border-color: transparent; }

@media (max-width: 900px) {
  body.theme-dark { display: block; }
  .theme-dark .sidebar { position: static; width: auto; height: auto; padding: 20px; }
  .theme-dark .sidebar-nav { flex-direction: row; flex-wrap: wrap; }
  .theme-dark .nav-link.active::before { display: none; }
  .theme-dark .container { padding: 24px 16px; }
}

/* Long URLs, links and messages wrap instead of widening the page. */
.theme-dark .link-box,
.theme-dark .site-chip,
.theme-dark .lead-field,
.theme-dark .lead-preview,
.theme-dark .lead-name,
.theme-dark .bubble-body,
.theme-dark .untracked-site { overflow-wrap: anywhere; min-width: 0; }
.theme-dark .site-chip { max-width: 100%; }
.theme-dark .lead-row-main { min-width: 0; }
.theme-dark .client-list-item > div { min-width: 0; }
.theme-dark .client-list-item > div > div:first-child { min-width: 0; flex: 1 1 260px; }

/* Stat cards: 3 across, then stack. */
@media (max-width: 1100px) {
  .theme-dark .sidebar { width: 220px; padding: 30px 18px; }
  .theme-dark .nav-link.active::before { left: -18px; }
  .theme-dark .container { padding: 30px 24px 48px; }
  .theme-dark .stat-row { gap: 14px; }
  .theme-dark .leads-list-header { flex-direction: column; align-items: flex-start; }
}

/* ---------- Client dashboard (no sidebar) ---------- */
body.theme-dark.no-sidebar { display: block; }
.theme-dark.no-sidebar .container { max-width: 1120px; margin: 0 auto; }
.theme-dark .stat-row-4 { grid-template-columns: repeat(4, 1fr); }
.theme-dark .stat-foot { margin-top: 8px; font-size: 11px; color: var(--muted); }
.theme-dark .stat-pill.pending { color: var(--cyan); background: rgba(0, 194, 255, 0.15); border-color: transparent; }
.theme-dark #leadsList > .stat-row { margin-bottom: 28px; }
.theme-dark.client-page #leadsList { background: transparent; border: none; padding: 0; }
.theme-dark.client-page #leadsList .leads-list-header {
  border: 0.6px solid var(--border);
  border-bottom: none;
  padding: 28px 28px 20px;
}
.theme-dark #leadsList > :is(.lead, .call-item, .text-item):last-child,
.theme-dark #leadsList > .kind-empty:last-child { border-radius: 0 0 12px 12px; }
@media (max-width: 1100px) { .theme-dark .stat-row-4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .theme-dark .stat-row-4 { grid-template-columns: 1fr; } }

/* ---------- Admin client list: name + View dashboard ---------- */
.theme-dark .client-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 16px 20px;
  background: var(--surface-2);
  border: 0.6px solid var(--border);
  border-radius: 8px;
  margin-bottom: 10px;
}
.theme-dark .client-row-name { font-size: 15px; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }
.theme-dark .client-row-actions { display: flex; gap: 8px; align-items: center; }
.theme-dark a.button-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 4px;
  background: var(--primary-grad);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}
.theme-dark a.button-link:hover { filter: brightness(1.1); }
.theme-dark .client-manage { flex-basis: 100%; margin-top: 8px; padding-top: 14px; border-top: 0.6px solid var(--border); }

/* Client dashboard sidebar views */
.theme-dark .traffic-view h2 { margin-bottom: 10px; }
.theme-dark .traffic-stats { display: flex; gap: 48px; margin-top: 8px; }

/* Clickable metric tiles on the client dashboard */
.theme-dark a.stat-link { text-decoration: none; color: var(--text); display: block; transition: border-color .15s, transform .15s; }
.theme-dark a.stat-link:hover { border-color: var(--primary); transform: translateY(-1px); }
.theme-dark a.stat-link.active { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset; }

/* This month / All time toggle */
.theme-dark .period-toggle {
  display: inline-flex;
  float: right;
  margin: -62px 0 0;
  background: var(--surface-2);
  border: 0.6px solid var(--border);
  border-radius: 4px;
  padding: 3px;
  gap: 2px;
}
.theme-dark .period-toggle button { background: transparent; color: var(--text-2); font-size: 12px; padding: 6px 12px; border-radius: 3px; }
.theme-dark .period-toggle button:hover { filter: none; color: var(--text); }
.theme-dark .period-toggle button.active { background: var(--primary-grad); color: #fff; }
.theme-dark #leadsList > .stat-row { clear: both; }
@media (max-width: 700px) { .theme-dark .period-toggle { float: none; margin: 0 0 14px; } }

.theme-dark .admin-back {
  margin-top: auto;
  margin-bottom: 12px;
  border: 0.6px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
}
.theme-dark .admin-back[hidden] { display: none; }
.theme-dark .admin-back + .sidebar-foot { margin-top: 0; }
.theme-dark .leads-empty {
  background: var(--surface);
  border: 0.6px solid var(--border);
  border-top: 0.6px solid #1c2541;
  border-radius: 0 0 12px 12px;
  text-align: center;
}

/* Website traffic chart (Search Console style) */
.gsc-ranges{display:flex;flex-wrap:wrap;gap:6px;margin-bottom:14px}
.gsc-ranges .gsc-range{background-image:none;box-shadow:none;font-weight:500;background:#0A1330;border:1px solid #343B4F;color:#AEB9E1;border-radius:999px;padding:5px 12px;font-size:12px;cursor:pointer}
.gsc-ranges .gsc-range.active{background:#CB3CFF;border-color:#CB3CFF;color:#fff}
.gsc-tiles{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;margin-bottom:14px}
@media (max-width:700px){.gsc-tiles{grid-template-columns:repeat(2,minmax(0,1fr))}}
.gsc-tiles .gsc-tile{background-image:none;box-shadow:none;font-weight:400;display:flex;flex-direction:column;align-items:flex-start;gap:4px;text-align:left;background:#0A1330;border:1px solid #343B4F;border-top:3px solid #343B4F;border-radius:10px;padding:10px 12px;cursor:pointer;color:#AEB9E1;min-width:0}
.gsc-tiles .gsc-tile.active{border-top-color:var(--m);background:#101d45}
.gsc-tile-label{font-size:12px;color:#AEB9E1}
.gsc-tile-value{font-size:22px;font-weight:600;color:#fff}
.gsc-chart{position:relative;width:100%;min-width:0}
.gsc-chart svg{display:block;max-width:100%;touch-action:pan-y}
.gsc-grid{stroke:#343B4F;stroke-width:1;opacity:.6}
.gsc-axis{fill:#7E89AC;font-size:11px}
.gsc-cross{stroke:#AEB9E1;stroke-width:1;stroke-dasharray:3 3}
.gsc-tip{position:absolute;top:8px;background:#0A1330;border:1px solid #343B4F;border-radius:8px;padding:8px 10px;font-size:12px;color:#AEB9E1;pointer-events:none;white-space:nowrap;box-shadow:0 6px 18px rgba(0,0,0,.35)}
.gsc-tip b{color:#fff;font-weight:600;margin-left:4px}
.gsc-tip-date{color:#fff;font-weight:600;margin-bottom:4px}
.gsc-key{display:inline-block;width:8px;height:8px;border-radius:2px;margin-right:6px}
.gsc-table-wrap{margin-top:12px;color:#AEB9E1;font-size:13px}
.gsc-table-wrap summary{cursor:pointer;color:#7E89AC}
.gsc-table{width:100%;border-collapse:collapse;margin-top:8px;font-size:12px}
.gsc-table th,.gsc-table td{text-align:right;padding:4px 8px;border-bottom:1px solid #343B4F}
.gsc-table th:first-child,.gsc-table td:first-child{text-align:left}
#gscTable{max-height:260px;overflow:auto}

/* Hamburger button: only shown on phones. */
.theme-dark .menu-toggle { display: none; }

/* ---------- Mobile (phones): sidebar becomes a sticky top bar + hamburger menu ---------- */
@media (max-width: 760px) {
  body.theme-dark { display: block; }
  .theme-dark .sidebar {
    position: sticky; top: 0; z-index: 30;
    width: auto; height: auto;
    padding: 10px 14px;
    border-right: none; border-bottom: 0.6px solid #1c2541;
    background: rgba(8, 16, 40, 0.97);
    backdrop-filter: blur(8px);
  }
  .theme-dark .sidebar-logo { font-size: 16px; margin: 0; min-height: 36px; }
  .theme-dark .sidebar-logo .logo-mark { width: 20px; height: 20px; }
  .theme-dark .menu-toggle {
    display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
    margin-left: auto; width: 40px; height: 40px; padding: 0 10px;
    background: transparent; background-image: none; box-shadow: none;
    border: 0.6px solid var(--border); border-radius: 8px; cursor: pointer;
  }
  .theme-dark .menu-toggle:hover, .theme-dark .menu-toggle:focus, .theme-dark .menu-toggle:active { background: var(--surface); background-image: none; filter: none; box-shadow: none; }
  .theme-dark .menu-toggle span { display: block; height: 2px; border-radius: 2px; background: var(--text); transition: transform .2s, opacity .2s; }
  .theme-dark .sidebar.menu-open .menu-toggle span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
  .theme-dark .sidebar.menu-open .menu-toggle span:nth-child(2) { opacity: 0; }
  .theme-dark .sidebar.menu-open .menu-toggle span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

  /* Menu panel drops down under the bar. */
  .theme-dark .sidebar-nav,
  .theme-dark .sidebar .admin-back,
  .theme-dark .sidebar-foot { display: none; }
  .theme-dark .sidebar.menu-open .sidebar-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 10px; }
  .theme-dark .sidebar.menu-open .admin-back:not([hidden]) { display: flex; margin: 8px 0 4px; }
  .theme-dark .sidebar.menu-open .nav-link { padding: 12px; font-size: 15px; border-radius: 8px; }
  .theme-dark .nav-link.active { background: rgba(203, 60, 255, 0.12); }
  .theme-dark .nav-link.active::before { display: none; }

  .theme-dark .container { padding: 18px 14px 40px; }
  .theme-dark .page-header h1 { font-size: 22px; }
  .theme-dark .card { padding: 18px 16px; margin-bottom: 18px; border-radius: 10px; }

  /* Metric tiles: two across, compact. */
  .theme-dark .stat-row,
  .theme-dark .stat-row-4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px; margin-bottom: 18px; }
  .theme-dark .stat-tile,
  .theme-dark .stat-tile:nth-child(2),
  .theme-dark .stat-tile:nth-child(3) { padding: 14px 12px; min-width: 0; }
  .theme-dark .stat-label { gap: 6px; font-size: 11px; }
  .theme-dark .stat-line { margin-top: 10px; flex-wrap: wrap; gap: 6px; }
  .theme-dark .stat-value { font-size: 22px; line-height: 26px; }
  .theme-dark .stat-foot { margin-top: 6px; font-size: 10px; }
  .theme-dark #leadsList > .stat-row { margin-bottom: 18px; }
  .theme-dark .stat-row:not(.stat-row-4) > .stat-tile:last-child:nth-child(odd) { grid-column: 1 / -1; }

  /* Leads timeline */
  .theme-dark.client-page #leadsList .leads-list-header,
  .theme-dark .leads-list-header { padding: 18px 16px 14px; }
  .theme-dark .kind-filter { display: flex; overflow-x: auto; scrollbar-width: none; max-width: 100%; }
  .theme-dark .kind-filter button { flex: 0 0 auto; white-space: nowrap; }
  .theme-dark .lead-row { padding: 12px 14px; gap: 8px; }
  .theme-dark .lead-row-top { flex-wrap: wrap; row-gap: 4px; }
  .theme-dark .lead-row-top .badge { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .theme-dark .type-pill, .theme-dark .lead-timestamp { white-space: nowrap; }
  .theme-dark .lead-details, .theme-dark .thread { padding-left: 14px; padding-right: 14px; }
  .theme-dark .call-icon-btn { width: 36px; height: 36px; flex-shrink: 0; }

  /* Admin client rows */
  .theme-dark .client-row-actions { width: 100%; }
  .theme-dark .client-row-actions > * { flex: 1 1 0; text-align: center; justify-content: center; white-space: nowrap; padding-left: 8px; padding-right: 8px; }
  .theme-dark .client-row { padding: 14px; }

  /* Traffic chart */
  .theme-dark .gsc-ranges { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 12px; padding: 0 16px; }
  .theme-dark .gsc-ranges .gsc-range { flex: 0 0 auto; white-space: nowrap; }
  .theme-dark .gsc-tiles { gap: 8px; }
  .theme-dark .gsc-tiles .gsc-tile { padding: 8px 10px; }
  .theme-dark .gsc-tile-value { font-size: 18px; }
}

/* Leads hero tile: first metric, full width above the others. */
.theme-dark .stat-row-4 > .stat-hero { grid-column: 1 / -1; background: linear-gradient(135deg, rgba(203,60,255,.16), rgba(127,37,251,.08)), var(--surface); border-color: rgba(203,60,255,.45); }
.theme-dark .stat-hero .stat-value { font-size: 34px; line-height: 40px; }
.theme-dark .stat-hero .stat-foot { font-size: 12px; color: var(--text-2); }
.theme-dark .stat-hero .swap { color: var(--text); font-weight: 600; }
@media (max-width: 760px) {
  .theme-dark .stat-row-4 > .stat-hero { grid-column: 1 / -1 !important; }
  .theme-dark .stat-hero .stat-value { font-size: 28px; line-height: 32px; }
  .theme-dark .stat-hero .stat-foot { font-size: 11px; }
}

/* ---------- Section pages (forms / calls / text-backs) ---------- */
.theme-dark .kind-view { margin-bottom: 24px; }
.theme-dark .kind-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 20px; }
.theme-dark .kind-tile { background: var(--bg); border: 0.6px solid var(--border); border-radius: 10px; padding: 14px 16px; min-width: 0; }
.theme-dark .kind-tile.accent { background: linear-gradient(135deg, rgba(203,60,255,.16), rgba(127,37,251,.08)), var(--bg); border-color: rgba(203,60,255,.45); }
.theme-dark .kind-tile-label { font-size: 12px; color: var(--text-2); }
.theme-dark .kind-tile-value { font-size: 28px; font-weight: 600; line-height: 34px; margin-top: 6px; color: var(--text); }
.theme-dark .kind-tile-foot { font-size: 11px; color: var(--muted); margin-top: 4px; }
.theme-dark .kind-chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; flex-wrap: wrap; }
.theme-dark .kind-chart-head h3 { font-size: 14px; font-weight: 600; margin: 0; color: var(--text); }
.theme-dark .kind-legend { display: flex; gap: 14px; font-size: 12px; color: var(--text-2); }
.theme-dark .kind-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.theme-dark .kind-chart { position: relative; width: 100%; min-width: 0; }
.theme-dark .kind-chart svg { display: block; max-width: 100%; touch-action: pan-y; }
.theme-dark .kind-hit { cursor: default; }
.theme-dark .kind-hit:hover { fill: rgba(174, 185, 225, 0.06); }
.theme-dark .kind-val { fill: var(--text); font-size: 11px; font-weight: 600; }
@media (max-width: 760px) {
  .theme-dark .kind-metrics { gap: 8px; }
  .theme-dark .kind-tile { padding: 10px; }
  .theme-dark .kind-tile-value { font-size: 20px; line-height: 24px; }
  .theme-dark .kind-tile-foot { font-size: 10px; }
}

.theme-dark .lead-controls button.delete-lead-btn.secondary { margin-left: auto; color: var(--red, #ff5a65); border-color: rgba(255, 90, 101, 0.45) !important; color: #ff6b75 !important; }
.theme-dark .lead-controls button.delete-lead-btn.secondary:hover { background: rgba(255, 90, 101, 0.12); }

.theme-dark .logo-accent { color: #CB3CFF; }

/* ---------- Login ---------- */
body.theme-dark.login-page { display: block; min-height: 100vh;
  background: radial-gradient(900px 500px at 15% -10%, rgba(203,60,255,.18), transparent 60%),
              radial-gradient(800px 500px at 110% 110%, rgba(0,194,255,.14), transparent 60%), var(--bg); }
.theme-dark .login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 16px; }
.theme-dark .login-card { width: 100%; max-width: 400px; background: var(--surface); border: 0.6px solid var(--border); border-radius: 14px; padding: 32px 28px; box-shadow: 0 20px 50px rgba(1,5,17,.45); }
.theme-dark .login-logo { margin-bottom: 28px; }
.theme-dark .login-card h1 { font-size: 22px; margin: 0 0 4px; }
.theme-dark .login-card .subtitle { color: var(--text-2); margin: 0 0 22px; font-size: 13px; }
.theme-dark .login-card label { display: block; margin-bottom: 6px; }
.theme-dark .login-card input { width: 100%; margin-bottom: 16px; }
.theme-dark .login-card button[type="submit"] { width: 100%; padding: 12px; font-size: 14px; font-weight: 600; border-radius: 6px; }
.theme-dark .login-card .status-banner { margin-bottom: 14px; }
.theme-dark .login-foot { margin-top: 18px; color: var(--muted); font-size: 12px; }
.theme-dark .google-btn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 12px; border-radius: 6px; background: #fff; color: #1f1f1f; font-weight: 600; font-size: 14px; text-decoration: none; border: 1px solid #dadce0; }
.theme-dark .google-btn:hover { background: #f3f4f6; }
.theme-dark .google-btn svg { width: 18px; height: 18px; }
.theme-dark .login-note { margin-top: 16px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.theme-dark .login-note a { color: var(--text-2); }
.theme-dark .login-card #banner { margin-bottom: 14px; }

/* Signed-in client account (sidebar foot) */
.theme-dark .account-box { margin-top: auto; padding: 12px 0 0; border-top: 0.6px solid #1c2541; }
.theme-dark .account-box + .sidebar-foot { margin-top: 10px; }
.theme-dark .account-email { font-size: 12px; color: var(--muted); padding: 0 12px 4px; overflow-wrap: anywhere; }
.theme-dark .dash-switch { width: 100%; margin-bottom: 10px; }
@media (max-width: 760px) {
  .theme-dark .account-box { display: none; }
  .theme-dark .sidebar.menu-open .account-box:not([hidden]) { display: block; margin-top: 8px; }
}

/* Client access tab */
.theme-dark .access-row { border: 0.6px solid var(--border); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface-2); }
.theme-dark .access-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.theme-dark .access-items { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.theme-dark .access-item { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--text-2); padding: 6px 8px; border-radius: 6px; background: rgba(255,255,255,.02); }
.theme-dark .access-item > span:first-child { flex: 1 1 220px; min-width: 0; overflow-wrap: anywhere; }
.theme-dark .new-code { border: 0.6px solid rgba(203,60,255,.5); background: rgba(203,60,255,.08); border-radius: 10px; padding: 14px; margin-bottom: 14px; }
.theme-dark .new-code-title { font-size: 13px; color: var(--text-2); }
.theme-dark .new-code-value { font-size: 26px; font-weight: 700; letter-spacing: 2px; margin: 6px 0 10px; font-family: ui-monospace, Menlo, monospace; color: #fff; }
.theme-dark .new-code textarea { width: 100%; background: var(--bg); color: var(--text-2); border: 0.6px solid var(--border); border-radius: 6px; padding: 8px; font-size: 12px; resize: vertical; }

.theme-dark .login-foot a { color: var(--muted); }
