:root {
  --bg: #0e1116;
  --bg-panel: #161b23;
  --bg-card: #1c2330;
  --bg-hover: #232c3d;
  --border: #2a3446;
  --text: #e8edf5;
  --text-dim: #94a3b8;
  --accent: #f5a623;
  --accent-dark: #d68910;
  --green: #34d399;
  --red: #f87171;
  --yellow: #fbbf24;
  --blue: #60a5fa;
  --radius: 10px;
  --sidebar-w: 220px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

#app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: sticky;
  top: 0;
  height: 100vh;
  flex-shrink: 0;
}
.logo { font-size: 20px; font-weight: 600; letter-spacing: -0.3px; }
.logo b { color: var(--accent); }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 9px 12px;
  border-radius: 8px;
  font-weight: 500;
}
.sidebar nav a:hover { background: var(--bg-hover); color: var(--text); }
.sidebar nav a.active { background: var(--bg-hover); color: var(--accent); }
.sidebar-foot { margin-top: auto; }

/* ---------- Main ---------- */
main { flex: 1; padding: 28px 34px; max-width: 1200px; min-width: 0; }
h1 { font-size: 24px; margin-bottom: 4px; letter-spacing: -0.4px; }
h2 { font-size: 17px; margin: 22px 0 10px; }
.subtitle { color: var(--text-dim); margin-bottom: 22px; }

/* ---------- Cards & layout ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.grid { display: grid; gap: 14px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stat-num { font-size: 28px; font-weight: 700; }
.stat-label { color: var(--text-dim); font-size: 13px; }

/* ---------- Forms ---------- */
input, select, textarea {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 13px; color: var(--text-dim); margin: 12px 0 5px; font-weight: 500; }
.search-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.search-row .field { flex: 1; min-width: 180px; }
.search-row label { margin-top: 0; }

button, .btn {
  background: var(--accent);
  color: #1a1205;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
  display: inline-block;
}
button:hover, .btn:hover { background: var(--accent-dark); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 6px; }
.btn-danger { background: transparent; border: 1px solid var(--border); color: var(--red); }
.btn-danger:hover { background: rgba(248,113,113,0.1); }

/* ---------- Table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left;
  padding: 10px 14px;
  background: var(--bg-panel);
  color: var(--text-dim);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
td { padding: 11px 14px; border-top: 1px solid var(--border); vertical-align: middle; }
tr.row-click { cursor: pointer; }
tr.row-click:hover td { background: var(--bg-hover); }
td .sub { color: var(--text-dim); font-size: 12.5px; }

/* ---------- Badges / scores ---------- */
.badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-muted { background: var(--bg-hover); color: var(--text-dim); }
.badge-green { background: rgba(52,211,153,0.15); color: var(--green); }
.badge-red { background: rgba(248,113,113,0.15); color: var(--red); }
.badge-yellow { background: rgba(251,191,36,0.15); color: var(--yellow); }
.badge-blue { background: rgba(96,165,250,0.15); color: var(--blue); }

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 4px 8px;
  border-radius: 8px;
  font-weight: 700;
  font-size: 14px;
}
.score-hot { background: rgba(248,113,113,0.18); color: var(--red); }
.score-warm { background: rgba(251,191,36,0.18); color: var(--yellow); }
.score-cold { background: rgba(52,211,153,0.18); color: var(--green); }

.banner {
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-bottom: 16px;
  font-size: 14px;
  border: 1px solid;
}
.banner-info { background: rgba(96,165,250,0.08); border-color: rgba(96,165,250,0.3); color: var(--blue); }
.banner-warn { background: rgba(251,191,36,0.08); border-color: rgba(251,191,36,0.3); color: var(--yellow); }

/* ---------- Filters ---------- */
.filter-bar { display: flex; gap: 8px; margin: 16px 0 12px; flex-wrap: wrap; align-items: center; }
.chip {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 20px;
  padding: 5px 13px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}
.chip.on { background: rgba(245,166,35,0.15); border-color: var(--accent); color: var(--accent); }

/* ---------- Pipeline ---------- */
.pipeline { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; align-items: start; }
.pipe-col { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; }
.pipe-col h3 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim); padding: 4px 6px 10px; }
.lead-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 13.5px;
}
.lead-card:hover { border-color: var(--accent); }
.lead-card .name { font-weight: 600; margin-bottom: 2px; }
.lead-card .meta { color: var(--text-dim); font-size: 12px; display: flex; justify-content: space-between; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex; align-items: center; justify-content: center;
  z-index: 100; padding: 20px;
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  max-width: 720px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 28px;
}
.modal h2 { margin-top: 0; }
.modal-close { float: right; background: transparent; color: var(--text-dim); font-size: 20px; padding: 0 6px; }
.modal-close:hover { background: transparent; color: var(--text); }

/* ---------- Findings list ---------- */
.finding { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.finding:last-child { border-bottom: none; }
.finding .icon { flex-shrink: 0; }
.finding .pitch { color: var(--text-dim); font-size: 13px; margin-top: 2px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  animation: slide-in 0.25s ease;
  box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
@keyframes slide-in { from { transform: translateX(30px); opacity: 0; } to { transform: none; opacity: 1; } }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.25);
  border-top-color: #1a1205;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--text-dim); }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
code.inline { background: var(--bg-panel); padding: 2px 6px; border-radius: 5px; font-size: 13px; }
textarea.script { font-family: ui-monospace, monospace; font-size: 13px; min-height: 150px; }

/* ---------- Report (print-ready, light theme) ---------- */
.report-page { background: #fff; color: #1a202c; border-radius: var(--radius); padding: 46px 52px; max-width: 820px; }
.report-page h1, .report-page h2 { color: #1a202c; }
.report-head { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 3px solid #f5a623; padding-bottom: 18px; margin-bottom: 24px; }
.report-agency { font-weight: 700; font-size: 18px; }
.report-agency .sub { font-weight: 400; color: #718096; font-size: 13px; }
.report-score-ring {
  width: 120px; height: 120px; border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-size: 34px; font-weight: 800; color: #fff; margin: 0 auto;
}
.report-grade { text-align: center; margin: 20px 0 28px; }
.report-grade .label { color: #718096; font-size: 13px; margin-top: 6px; }
.report-section { margin-bottom: 26px; }
.report-finding { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid #e2e8f0; font-size: 14px; }
.report-finding .pitch { color: #4a5568; font-size: 13px; margin-top: 2px; }
.report-cta { background: #fff7e8; border: 1px solid #f5a623; border-radius: 10px; padding: 18px 22px; margin-top: 26px; }
.report-cta h3 { margin-bottom: 6px; }
.report-meta-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 20px; font-size: 14px; }
.report-meta-grid .k { color: #718096; }

@media print {
  body { background: #fff; }
  .sidebar, .no-print, #toast-root { display: none !important; }
  main { padding: 0; max-width: none; }
  .report-page { border-radius: 0; padding: 20px 10px; max-width: none; }
}

@media (max-width: 760px) {
  #app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 14px; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { display: none; }
  main { padding: 18px 16px; }
}
