:root {
  --accent: #b6e62e;
  --accent-dark: #9bc91f;
  --accent-soft: #eef9c9;
  --bg: #f6f7f4;
  --card: #ffffff;
  --ink: #1c1f17;
  --muted: #8a8f82;
  --line: #e9ebe4;
  --high: #b6e62e;
  --mid: #f4b740;
  --low: #d9dcd2;
  --danger: #e2574c;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(30, 35, 20, 0.06);
  --shadow-lg: 0 8px 30px rgba(30, 35, 20, 0.08);
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); }
a { color: inherit; }

/* --- App shell --- */
body.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--card); border-right: 1px solid var(--line);
  padding: 24px 16px; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.content { flex: 1; padding: 32px 40px; max-width: 1200px; }

.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 24px; }
.brand--center { justify-content: center; padding-bottom: 8px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; background: var(--accent);
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.3px; }

.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  text-decoration: none; color: var(--ink); font-size: 14px; font-weight: 500; transition: background .15s;
}
.nav-item:hover { background: var(--bg); }
.nav-item.is-active { background: var(--accent); font-weight: 600; }
.nav-item .ico { font-size: 16px; }
.logout { margin-top: auto; }
.btn-ghost { width: 100%; background: none; border: 1px solid var(--line); border-radius: 10px; padding: 10px; cursor: pointer; color: var(--muted); }
.btn-ghost:hover { color: var(--ink); }

/* --- Headings --- */
.page-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; }
.page-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -0.5px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.back-link { text-decoration: none; color: var(--muted); font-size: 13px; }

/* --- Stat cards --- */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow);
}
.stat--accent { background: var(--accent); border-color: var(--accent-dark); }
.stat-label { font-size: 13px; color: var(--muted); }
.stat--accent .stat-label { color: #4f5d12; }
.stat-value { font-size: 28px; font-weight: 700; }
.stat-sub { font-size: 12px; color: var(--muted); }
.stat--accent .stat-sub { color: #4f5d12; }

/* --- Cards --- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card h3 { margin: 0 0 12px; font-size: 15px; }

/* --- Search bar --- */
.search-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-row input[type=text], .search-row input[type=url] { flex: 1; min-width: 180px; }
input, textarea, select {
  font: inherit; padding: 11px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); border-color: var(--accent); }
input[type=number] { width: 80px; }
.chk { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 11px 20px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; font-weight: 600; font-size: 14px; text-decoration: none; transition: transform .05s, background .15s; }
.btn:active { transform: translateY(1px); }
.btn--primary { background: var(--accent); color: #2c350a; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { background: var(--bg); }
.btn--block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-group { display: flex; gap: 8px; flex-wrap: wrap; margin: 8px 0; }

.search-status { margin-top: 10px; font-size: 13px; min-height: 18px; }
.search-status.err { color: var(--danger); }
.search-status.ok { color: var(--accent-dark); }

/* --- Toolbar --- */
.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.filters { display: flex; gap: 10px; }
.select { padding: 9px 12px; }

/* --- Table --- */
.table-wrap { padding: 0; overflow-x: auto; }
.leads-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.leads-table thead th { text-align: left; padding: 14px 16px; color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; border-bottom: 1px solid var(--line); }
.leads-table tbody td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.leads-table tbody tr:hover { background: #fbfcf8; }
.col-chk, .col-num { width: 36px; }
.lead-name { font-weight: 600; text-decoration: none; }
.lead-name:hover { text-decoration: underline; }
.lead-domain { font-size: 12px; color: var(--muted); }
.tech-badge { display: inline-block; margin-top: 4px; font-size: 11px; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 2px 7px; color: var(--muted); }
.score { display: inline-block; margin-right: 8px; font-variant-numeric: tabular-nums; }
.social a { text-decoration: none; margin-right: 6px; }
.empty-row td { text-align: center; color: var(--muted); padding: 40px; }

.pot-badge { display: inline-block; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.pot-high { background: var(--accent); color: #2c350a; }
.pot-mid { background: var(--mid); color: #5a3d00; }
.pot-low { background: var(--low); color: #555; }
.badge-lg { font-size: 14px; padding: 8px 18px; }

/* --- Login --- */
body.bare { background: var(--bg); }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { background: var(--card); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 36px; width: 100%; max-width: 380px; }
.login-sub { text-align: center; color: var(--muted); margin: 4px 0 20px; }
.form { display: flex; flex-direction: column; gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field textarea, .field select { color: var(--ink); }
.alert { padding: 10px 14px; border-radius: 10px; font-size: 14px; margin-bottom: 12px; }
.alert--error { background: #fdeceb; color: var(--danger); }

/* --- Detail --- */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.kv { display: grid; grid-template-columns: 120px 1fr; gap: 8px 12px; margin: 0 0 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.problem-list { margin: 0 0 12px; padding-left: 18px; font-size: 14px; }
.problem-list li { margin-bottom: 4px; }
.ai-box { background: var(--accent-soft); border-radius: 10px; padding: 14px; font-size: 14px; line-height: 1.55; }
.draft-box { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.draft-subject { width: 100%; }
.legal-note { font-size: 12px; color: var(--muted); border-left: 3px solid var(--mid); padding-left: 10px; }
.hidden { display: none; }
.result-scores { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 20px; }

@media (max-width: 880px) {
  .stats, .result-scores { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  body.app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; flex-wrap: wrap; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .content { padding: 20px; }
}
