:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --ink: #14203a;
  --muted: #6a768c;
  --line: #e2e7ef;
  --accent: #1f5fd6;
  --accent-soft: #e8f0fe;
  --gold: #c8951a;
  --green: #1f9d55;
  --red: #d64545;
  --shadow: 0 1px 3px rgba(20, 32, 58, .08), 0 8px 24px rgba(20, 32, 58, .06);
  --radius: 10px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

/* ---------------- top bar ---------------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 14px 22px;
  background: linear-gradient(120deg, #14203a, #1c2c4d);
  color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  font-size: 22px; color: var(--gold);
  width: 40px; height: 40px; display: grid; place-items: center;
  background: rgba(255,255,255,.08); border-radius: 10px;
}
.topbar h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
.topbar .sub { margin: 2px 0 0; font-size: 12px; color: #9fb0cc; }
.stat-strip { display: flex; gap: 10px; flex-wrap: wrap; margin-left: auto; }
.stat {
  background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.09);
  border-radius: 8px; padding: 6px 12px; text-align: center; min-width: 78px;
}
.stat .num { font-size: 18px; font-weight: 700; display: block; line-height: 1.1; }
.stat .lbl { font-size: 10.5px; color: #9fb0cc; text-transform: uppercase; letter-spacing: .5px; }
.export {
  color: #fff; text-decoration: none; font-size: 12.5px; font-weight: 600;
  border: 1px solid rgba(255,255,255,.25); border-radius: 8px; padding: 8px 12px;
  white-space: nowrap;
}
.export:hover { background: rgba(255,255,255,.12); }
button.export { font-family: inherit; cursor: pointer; }
.export.add-firm { background: var(--gold); border-color: var(--gold); color: #14203a; }
.export.add-firm:hover { background: #d8a52f; }

/* ---------------- controls ---------------- */
.controls {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 12px 22px; background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 30;
}
#search {
  flex: 1 1 240px; min-width: 200px; max-width: 340px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px;
}
#search:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
.spacer { flex: 1 1 auto; }
#sort {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  font-size: 12.5px; background: #fff;
}
.score-filter { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.score-filter b { color: var(--ink); }
#f-score { width: 96px; accent-color: var(--accent); }
.chk { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 4px; cursor: pointer; }

.viewtoggle { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.viewtoggle button {
  border: 0; background: #fff; padding: 7px 14px; font-size: 12.5px; cursor: pointer; color: var(--muted);
}
.viewtoggle button.active { background: var(--accent); color: #fff; font-weight: 600; }

/* custom filter dropdowns */
.filter { position: relative; }
.filter > .filter-btn {
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  font-size: 12.5px; cursor: pointer; white-space: nowrap; display: inline-flex; gap: 6px; align-items: center;
}
.filter > .filter-btn.has-sel { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.filter > .filter-btn .caret { font-size: 9px; color: var(--muted); }
.filter .badge {
  background: var(--accent); color: #fff; border-radius: 10px; font-size: 10px;
  padding: 1px 6px; font-weight: 700;
}
.filter-menu {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 50;
  background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow);
  padding: 6px; min-width: 190px; max-height: 320px; overflow: auto;
}
.filter-menu label {
  display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 6px;
  font-size: 12.5px; cursor: pointer;
}
.filter-menu label:hover { background: var(--bg); }
.filter-menu input { accent-color: var(--accent); }

/* ---------------- main / table ---------------- */
main { padding: 16px 22px 60px; }
.result-count { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; box-shadow: var(--shadow); }
table { border-collapse: collapse; width: 100%; min-width: 900px; }
thead th {
  position: sticky; top: 0; background: #f0f3f8; z-index: 5;
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
  color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
tbody td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f9fc; }
.c-star { width: 30px; text-align: center; }
.c-score { width: 62px; }
.star { cursor: pointer; color: #cdd5e2; font-size: 15px; }
.star.on { color: var(--gold); }
.firm-name { font-weight: 600; color: var(--ink); }
.firm-type { font-size: 11.5px; color: var(--muted); }
.score-pill {
  display: inline-block; min-width: 34px; text-align: center; font-weight: 700;
  padding: 3px 7px; border-radius: 6px; font-size: 12px;
}
.muted { color: var(--muted); font-size: 12.5px; }
.c-emp { width: 78px; }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-size: 12.5px; color: var(--ink); white-space: nowrap; }
thead th.c-emp { text-align: right; }

/* tier + band + status chips */
.chip { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.tier-1 { background: #fbeecb; color: #8a6205; }
.tier-2 { background: #e3ecfb; color: #2456ab; }
.tier-3 { background: #eef1f6; color: #5b6c86; }
.tier-4 { background: #f2eef6; color: #6b4e8a; }

.st { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
.st .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.st-not-started .dot { background: #b8c1d1; }
.st-researching .dot, .st-watchlist .dot { background: #d89b1a; }
.st-networking .dot { background: #7a5cd6; }
.st-applied .dot { background: var(--accent); }
.st-interviewing .dot { background: #0e9d9d; }
.st-offer .dot { background: var(--green); }
.st-rejected .dot, .st-passed .dot { background: var(--red); }

/* ---------------- pipeline board ---------------- */
.board { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 12px; }
.col { flex: 0 0 236px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; max-height: 74vh; }
.col h3 { margin: 0; padding: 10px 12px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; }
.col .cards { padding: 8px; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.card { border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; cursor: pointer; background: #fff; }
.card:hover { border-color: var(--accent); }
.card .cn { font-weight: 600; font-size: 13px; }
.card .cm { font-size: 11px; color: var(--muted); margin-top: 2px; display: flex; justify-content: space-between; }

/* ---------------- drawer ---------------- */
.overlay { position: fixed; inset: 0; background: rgba(20,32,58,.35); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(480px, 94vw);
  background: var(--panel); z-index: 70; box-shadow: -8px 0 30px rgba(20,32,58,.18);
  overflow-y: auto; padding: 22px 24px 60px;
}
.drawer .close { position: absolute; top: 16px; right: 18px; border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.drawer h2 { margin: 0 22px 2px 0; font-size: 20px; }
.drawer .d-sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.d-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.d-block { margin-bottom: 16px; }
.d-block h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 0 0 5px; }
.d-block p { margin: 0; font-size: 13px; }

/* firm-details (enrichment) block */
.firm-details { background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.firm-details h4 { display: flex; align-items: center; gap: 8px; }
.firm-desc { margin: 0 0 10px; font-size: 13px; line-height: 1.45; color: var(--ink); }
.muted-hint { color: var(--muted); font-size: 12.5px; font-style: italic; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 6px 16px; }
.fact { display: flex; flex-direction: column; gap: 1px; }
.fact .fk { font-size: 10.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.fact .fv { font-size: 13px; color: var(--ink); }
.chip.enrich-auto { background: #fbf3dd; color: #8a6205; text-transform: none; letter-spacing: 0; }
.chip.enrich-ok { background: #e6f6ec; color: #177a43; text-transform: none; letter-spacing: 0; }
.section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); font-weight: 600; margin: 20px 0 8px; display: flex; align-items: center; gap: 8px; }
.d-fit { background: var(--accent-soft); border-left: 3px solid var(--accent); padding: 10px 12px; border-radius: 6px; }
.lens-label { font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); margin: 4px 0 8px; font-weight: 600; }
.fit-card { border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; }
.td-card { background: linear-gradient(120deg, #f5f8ff, #eef3fb); border: 1px solid #d5e0f5; }
.prod-card { background: linear-gradient(120deg, #fbf7ef, #f6f0e2); border: 1px solid #ecdfc4; }
.td-head { display: flex; align-items: center; justify-content: space-between; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); font-weight: 700; }
.prod-head { color: var(--gold); }
.td-role { font-size: 15px; font-weight: 700; color: var(--ink); margin: 6px 0 4px; }
.td-pitch { margin: 6px 0 0; font-size: 12.5px; color: #37445c; line-height: 1.5; }
.prod-angle { color: #6a5a34; }
.lenstoggle button.active { background: var(--gold); }
.lenstoggle button[data-lens="td"].active { background: var(--accent); }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; font-family: inherit;
}
.field textarea { min-height: 84px; resize: vertical; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.save-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
.btn { background: var(--accent); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font-size: 13px; font-weight: 600; cursor: pointer; }
.btn:hover { background: #1a52ba; }
.saved-note { font-size: 12px; color: var(--green); opacity: 0; transition: opacity .2s; }
.saved-note.show { opacity: 1; }
.saved-note.err { color: var(--red); }
.d-link { color: var(--accent); font-size: 12.5px; word-break: break-all; }

@media (max-width: 720px) {
  .stat-strip { order: 3; width: 100%; margin-left: 0; }
  .export { margin-left: auto; }
}
