/* Lead Engine dashboard — sidebar layout */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 220px;
  --sidebar-bg: #0f1117;
  --sidebar-border: #1e2130;
  --sidebar-text: #8b8fa8;
  --sidebar-text-hover: #ffffff;
  --sidebar-active-bg: #1a1e2e;
  --sidebar-active-text: #ffffff;
  --accent: #4ade80;
  --accent-hover: #22c55e;
  --bg: #f5f7fa;
  --card-bg: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  /* page shell: sidebar left, content right */
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: 1fr;
  min-height: 100vh;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  grid-column: 1;
  grid-row: 1;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  /* stay fixed while content scrolls */
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 24px 20px 20px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-brand .brand-name {
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  display: block;
}
.sidebar-brand .brand-sub {
  color: var(--sidebar-text);
  font-size: 11px;
  margin-top: 3px;
  display: block;
}

.sidebar-nav {
  padding: 12px 0;
  flex: 1;
}

.nav-section {
  padding: 16px 16px 6px;
  font-size: 10px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #3d4159;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.nav-item:hover {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}
.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--accent);
}
.nav-item .icon {
  width: 16px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}
.nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #000;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 10px;
  line-height: 1.4;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 12px;
  color: var(--sidebar-text);
  flex-shrink: 0;
}

/* ── Main content ─────────────────────────────────────── */
.main-wrap {
  grid-column: 2;
  grid-row: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

main {
  padding: 28px;
  max-width: 1200px;
  width: 100%;
  flex: 1;
}

h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 17px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

/* ── Stat cards ───────────────────────────────────────── */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(155px, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border: 1px solid var(--border);
}
.stat-card .label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .6px;
  font-weight: 500;
}
.stat-card .value {
  font-size: 30px;
  font-weight: 800;
  margin-top: 8px;
  color: var(--text);
}
.stat-card .value.green  { color: #16a34a; }
.stat-card .value.yellow { color: #d97706; }
.stat-card .value.blue   { color: #2563eb; }
.stat-card .value.purple { color: #7c3aed; }

/* ── Cards ────────────────────────────────────────────── */
.card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 22px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border: 1px solid var(--border);
  margin-bottom: 20px;
}

/* ── Tables ───────────────────────────────────────────── */
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { background: #f9fafb; font-size: 11px; text-transform: uppercase; color: var(--muted); letter-spacing: .5px; font-weight: 600; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }

/* Leads table: tighter cell padding so all columns fit */
table.leads-table th,
table.leads-table td { padding: 9px 10px; }
table.leads-table { table-layout: fixed; }

/* ── Badges ───────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-yellow { background: #fef9c3; color: #a16207; }
.badge-red    { background: #fee2e2; color: #dc2626; }
.badge-gray   { background: #f3f4f6; color: #374151; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }

/* ── Filters ──────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
  margin-bottom: 18px;
}
.filters label { font-size: 12px; color: var(--muted); display: block; margin-bottom: 4px; font-weight: 500; }
.filters input, .filters select {
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 13.5px;
  min-width: 130px;
  background: #fff;
  color: var(--text);
}
.filters input:focus, .filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(74,222,128,.15);
}

/* ── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 17px;
  border-radius: 7px;
  background: var(--accent);
  color: #000;
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-weight: 600;
  transition: background .15s;
  text-decoration: none;
}
.btn:hover { background: var(--accent-hover); text-decoration: none; color: #000; }
.btn.secondary { background: #f3f4f6; color: #374151; }
.btn.secondary:hover { background: #e5e7eb; color: #111; }
.btn.warn { background: #f97316; color: #fff; }
.btn.warn:hover { background: #ea580c; }
.btn.outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn.outline:hover { background: #f9fafb; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

/* ── Actions page ─────────────────────────────────────── */
.action-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 16px; }
.action-card {
  background: var(--card-bg);
  padding: 20px;
  border-radius: 10px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  border: 1px solid var(--border);
}
.action-card h3 { font-size: 15px; margin-bottom: 6px; }
.action-card form { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.action-card input { padding: 8px 11px; border: 1px solid var(--border); border-radius: 7px; font-size: 13.5px; }
.action-card input:focus { outline: none; border-color: var(--accent); }

/* ── Pager ────────────────────────────────────────────── */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.pager a, .pager span {
  padding: 6px 13px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  color: var(--text);
}
.pager a:hover { background: #f9fafb; text-decoration: none; }
.pager .current { background: var(--sidebar-bg); color: #fff; border-color: var(--sidebar-bg); }

/* ── Lead info grid (detail page top card) ────────────── */
.lead-info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
.info-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.info-item:nth-child(3n) { border-right: none; }
.info-item--wide {
  grid-column: span 3;
  border-right: none;
}
.info-item:last-child, .info-item:nth-last-child(2):not(.info-item--wide) { border-bottom: none; }
.info-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--muted);
  font-weight: 600;
}
.info-value {
  font-size: 14px;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

/* ── Section label (audit subsections) ───────────────── */
.section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .7px;
  color: var(--muted);
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  margin-bottom: 10px;
}

/* ── Audit checks grid ────────────────────────────────── */
.audit-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; }
.audit-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
  gap: 8px;
}
.audit-item:nth-child(odd)  { background: #fafbfc; }
.audit-item:nth-child(even) { background: #fff; }
.audit-item .check-label { color: var(--muted); flex: 1; }
.audit-item .check-val   { font-weight: 600; white-space: nowrap; }
.check-pass { color: #16a34a; }
.check-fail { color: #dc2626; }
.check-num  { color: var(--text); }

/* ── Rating display ──────────────────────────────────── */
.rating {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-weight: 600;
  color: #f59e0b;
  font-size: 13px;
}

/* ── Misc ─────────────────────────────────────────────── */
.muted { color: var(--muted); }
.empty { padding: 48px; text-align: center; color: var(--muted); font-size: 14px; }
pre { background: #f8fafc; padding: 14px; border-radius: 8px; overflow-x: auto; font-size: 12.5px; border: 1px solid var(--border); }
code { font-size: 12px; background: #f3f4f6; padding: 2px 6px; border-radius: 4px; }
.warning-banner {
  background: #fff7ed;
  border-left: 4px solid #f97316;
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  font-size: 13.5px;
  margin-bottom: 16px;
}

/* ── Login ────────────────────────────────────────────── */
body.login-page {
  display: block;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 20% 10%, #1a2332 0%, transparent 50%),
    radial-gradient(ellipse at 80% 90%, #14201a 0%, transparent 45%),
    #0f1117;
}
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 380px;
  background: #161a24;
  border: 1px solid #1e2130;
  border-radius: 14px;
  padding: 32px 28px 28px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
}
.login-brand { margin-bottom: 24px; }
.login-brand .brand-name {
  display: block;
  color: #fff;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.3px;
}
.login-brand .brand-sub {
  display: block;
  margin-top: 4px;
  color: #8b8fa8;
  font-size: 13px;
}
.login-error {
  background: #3f1d1d;
  border: 1px solid #7f1d1d;
  color: #fecaca;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
}
.login-form label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #8b8fa8;
  margin-bottom: 6px;
}
.login-form input[type="text"],
.login-form input[type="password"] {
  width: 100%;
  padding: 11px 12px;
  margin-bottom: 14px;
  border: 1px solid #2a2f42;
  border-radius: 8px;
  background: #0f1117;
  color: #fff;
  font-size: 14px;
}
.login-form input:focus {
  outline: none;
  border-color: var(--accent);
}
.login-submit {
  width: 100%;
  margin-top: 6px;
  padding: 12px;
  font-size: 14px;
  font-weight: 700;
}
.logout-link {
  display: block;
  margin-top: 8px;
  color: #8b8fa8;
  font-size: 12px;
}
.logout-link:hover { color: #fff; text-decoration: none; }

