:root{
  --ink:#233445;
  --ink-2:#53616E;
  --slate:#3c4a63;
  --muted:#707d92;
  --paper:#f4f5f7;
  --card:#ffffff;
  --line:#e2e5ea;
  --line-strong:#c9ced8;
  --green:#2f6d4f;
  --rust:#9a4a34;
  --focus:#2f6fed;
  --radius:6px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
*{box-sizing:border-box;}
html,body{margin:0;padding:0;height:100%;}
body{
  font-family:var(--sans);
  background:var(--paper);
  color:var(--slate);
  font-size:14px;
  -webkit-font-smoothing:antialiased;
}
button{font-family:inherit;}
:focus-visible{outline:2px solid var(--focus); outline-offset:1px;}

#app{
  display:grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto 1fr;
  height:100vh;
}
header.topbar{
  grid-column: 1 / 3;
  background:var(--ink);
  color:#fff;
  display:flex;
  align-items:center;
  gap:20px;
  padding:0 20px;
  height:60px;
  border-bottom:3px solid var(--ink-2);
}
header.topbar .brand{ display:flex; align-items:center; gap:12px; white-space:nowrap; }
header.topbar .brand-logo{ height:32px; width:auto; display:block; }
header.topbar h1{ font-size:16px; font-weight:600; margin:0; letter-spacing:.01em; padding-left:12px; border-left:1px solid rgba(255,255,255,.25); }
header.topbar .searchwrap{ flex:1; max-width:640px; position:relative; }
header.topbar input[type="search"]{
  width:100%; background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.18);
  color:#fff; padding:9px 12px 9px 34px; border-radius:6px; font-size:14px;
}
header.topbar input[type="search"]::placeholder{ color:rgba(255,255,255,.55); }
header.topbar input[type="search"]:focus-visible{ outline:2px solid #fff; }
header.topbar .searchwrap svg{ position:absolute; left:10px; top:50%; transform:translateY(-50%); width:15px; height:15px; opacity:.6; }
header.topbar .count{ font-family:var(--mono); font-size:12px; color:rgba(255,255,255,.75); white-space:nowrap; }
header.topbar .count b{ color:#fff; font-weight:600; }
header.topbar .add-btn{
  display:flex; align-items:center; gap:6px;
  background:#fff; color:var(--ink); border:none;
  padding:9px 14px; border-radius:6px; font-size:13px; font-weight:700; cursor:pointer;
  white-space:nowrap;
}
header.topbar .add-btn:hover{ background:#e3e9ef; }
header.topbar .add-btn svg{ width:15px; height:15px; }
header.topbar .add-btn.secondary{ background:rgba(255,255,255,.1); color:#fff; border:1px solid rgba(255,255,255,.25); }
header.topbar .add-btn.secondary:hover{ background:rgba(255,255,255,.18); }
.icon-btn{
  background:rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.2); color:#fff;
  width:34px; height:34px; border-radius:6px; display:flex; align-items:center; justify-content:center;
  cursor:pointer; flex:none;
}
.icon-btn:hover{ background:rgba(255,255,255,.16); }
.icon-btn svg{ width:16px; height:16px; }

nav.sidebar{ background:var(--ink); color:#e9edf3; overflow-y:auto; padding:18px 16px 40px; }
nav.sidebar .filter-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
nav.sidebar .filter-head span{ font-size:11px; text-transform:uppercase; letter-spacing:.12em; color:rgba(255,255,255,.55); }
#clearAll{ background:none; border:1px solid rgba(255,255,255,.25); color:#fff; font-size:11px; padding:4px 9px; border-radius:20px; cursor:pointer; }
#clearAll:hover{ background:rgba(255,255,255,.1); }
.filter-group{ margin-bottom:20px; border-bottom:1px solid rgba(255,255,255,.1); padding-bottom:16px; }
.filter-group:last-child{ border-bottom:none; }
.filter-group h3{ font-size:12px; font-weight:600; margin:0 0 9px; color:#fff; display:flex; align-items:center; gap:6px; }
.filter-group h3 .n{ color:rgba(255,255,255,.7); font-family:var(--mono); font-weight:500; font-size:11px; }
.chiplist{ display:flex; flex-wrap:wrap; gap:6px; }
.chip{
  font-size:12px; padding:5px 10px; border-radius:14px; border:1px solid rgba(255,255,255,.22);
  background:rgba(255,255,255,.04); color:#dfe4ec; cursor:pointer; user-select:none;
  transition:background .12s, border-color .12s;
}
.chip:hover{ background:rgba(255,255,255,.1); }
.chip.active{ background:#fff; border-color:#fff; color:var(--ink); font-weight:600; }
.combo{ position:relative; }
.combo > input{
  width:100%; background:rgba(255,255,255,.06); border:1px solid rgba(255,255,255,.2);
  color:#fff; padding:7px 10px; border-radius:5px; font-size:12.5px; margin-bottom:6px;
}
.combo > input::placeholder{ color:rgba(255,255,255,.45); }
.combo-list{ max-height:180px; overflow-y:auto; overflow-x:hidden; border:1px solid rgba(255,255,255,.12); border-radius:5px; background:rgba(0,0,0,.18); width:100%; box-sizing:border-box; }
.combo-list label{ display:flex; align-items:flex-start; gap:7px; font-size:12.5px; padding:5px 8px; cursor:pointer; line-height:1.3; color:#fff; width:100%; box-sizing:border-box; }
.combo-list label input[type="checkbox"]{ margin-top:2px; }
.combo-list label span{ color:#fff; flex:1 1 auto; min-width:0; white-space:normal; overflow-wrap:break-word; word-break:break-word; }
.combo-list label:hover{ background:rgba(255,255,255,.1); }
.combo-list input[type="checkbox"]{ accent-color:#fff; flex:none; }
.selected-tags{ display:flex; flex-wrap:wrap; gap:5px; margin-top:7px; }
.selected-tags .tag{
  font-size:11px; background:rgba(255,255,255,.18); color:#fff; border:1px solid rgba(255,255,255,.35);
  padding:3px 7px 3px 9px; border-radius:12px; display:flex; align-items:center; gap:5px;
}
.selected-tags .tag button{ background:none;border:none;color:inherit;cursor:pointer;font-size:13px;line-height:1;padding:0; }

main{ overflow:auto; background:var(--paper); padding:16px 20px 40px; }
.toolbar{ display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:10px; }
.active-filters{ display:flex; gap:6px; flex-wrap:wrap; font-size:12px; color:var(--muted); }
.active-filters .pill{ background:var(--card); border:1px solid var(--line-strong); border-radius:12px; padding:3px 8px; display:flex; gap:5px; align-items:center; }
.active-filters .pill button{ border:none;background:none;cursor:pointer;color:var(--rust); font-weight:700; }
.export-btn{
  display:flex; align-items:center; gap:7px; background:var(--ink); color:#fff; border:1px solid var(--ink);
  padding:8px 14px; border-radius:5px; font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap; flex:none;
}
.export-btn:hover{ background:var(--ink-2); }
.export-btn svg{ width:14px; height:14px; }
.export-btn:disabled{ opacity:.6; cursor:default; }

.selection-bar{
  display:flex; align-items:center; gap:14px;
  background:#eef2f7; border:1px solid #cdd9e6; border-radius:6px;
  padding:10px 14px; margin-bottom:10px; font-size:13px; color:var(--ink);
}
.selection-bar.hidden{ display:none; }
.selection-bar .selection-count{ font-weight:700; }
.selection-bar .spacer{ flex:1; }
.link-btn{ background:none; border:none; color:var(--ink); text-decoration:underline; font-size:13px; cursor:pointer; padding:0; }
.selection-bar .btn-secondary, .selection-bar .btn-primary{ padding:7px 14px; font-size:12.5px; }

td.checkbox-col, th.checkbox-col{ width:36px; padding-left:14px; padding-right:0; }
td.checkbox-col input, th.checkbox-col input{ accent-color:var(--ink); cursor:pointer; }
tbody tr[data-id].row-selected{ background:#eaf1f8; }
.enrichment-badge{ font-size:10px; font-weight:700; letter-spacing:.04em; text-transform:uppercase; padding:1px 6px; border-radius:3px; margin-left:5px; background:#eaf1ff; color:#2f5fc4; border:1px solid #c6d9f7; }
.enrichment-badge.demo{ background:#fdeee0; color:#a8622a; border-color:#f0cba0; }

.modal-narrow{ max-width:480px; }
.settings-section-title{ font-size:13px; font-weight:700; color:var(--ink); margin:0 0 8px; }
.settings-status{ margin-top:10px; font-size:13px; }
.settings-status .status-line{ display:flex; align-items:center; gap:7px; }
.settings-status .dot-connected{ width:8px; height:8px; border-radius:50%; background:var(--green); flex:none; }
.settings-status .dot-demo{ width:8px; height:8px; border-radius:50%; background:#c98a2b; flex:none; }

.credit-warning{
  background:#fff4e0; border:1px solid #f0d29c; border-radius:6px; padding:12px 14px;
  font-size:13px; color:#7a4f10; margin-bottom:14px; display:flex; gap:10px; align-items:flex-start;
}
.credit-warning svg{ width:18px; height:18px; flex:none; margin-top:1px; color:#b9791f; }
.credit-warning-danger{ background:#fce8e4; border-color:#e3a494; color:#7a2a17; }
.credit-warning-danger svg{ color:#c14a2e; }
.demo-notice{
  background:#eef2f7; border:1px solid #d6dee8; border-radius:6px; padding:12px 14px;
  font-size:13px; color:var(--slate); margin-bottom:14px;
}
.enrich-preview-table{ width:100%; border-collapse:collapse; font-size:12.5px; margin-bottom:6px; }
.enrich-preview-table th{ text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.03em; color:var(--muted); padding:6px 8px; border-bottom:1px solid var(--line); }
.enrich-preview-table td{ padding:6px 8px; border-bottom:1px solid var(--line); vertical-align:top; }
.enrich-preview-table tr:last-child td{ border-bottom:none; }
.enrich-preview-scroll{ max-height:280px; overflow-y:auto; border:1px solid var(--line); border-radius:6px; margin-bottom:12px; }
.enrich-result-summary{ text-align:center; padding:10px 0; }
.enrich-result-summary .big-number{ font-size:32px; font-weight:700; color:var(--ink); }
.enrich-result-summary .label{ font-size:13px; color:var(--muted); margin-top:4px; }
.enrich-result-grid{ display:grid; grid-template-columns:1fr 1fr; gap:12px; margin-top:16px; }
.enrich-result-grid-3{ grid-template-columns:1fr 1fr 1fr; }
.enrich-result-grid .stat{ background:#f7f8fa; border:1px solid var(--line); border-radius:6px; padding:12px; text-align:center; }
.enrich-result-grid .stat .n{ font-size:20px; font-weight:700; color:var(--ink); }
.enrich-result-grid .stat .l{ font-size:11.5px; color:var(--muted); margin-top:2px; }

table{ width:100%; border-collapse:collapse; background:var(--card); border:1px solid var(--line); border-radius:var(--radius); overflow:hidden; }
thead th{
  position:sticky; top:0; z-index:2; background:var(--ink); color:#fff; text-align:left; font-size:11.5px;
  letter-spacing:.04em; text-transform:uppercase; padding:10px 12px; font-weight:600; cursor:pointer;
  white-space:nowrap; border-right:1px solid rgba(255,255,255,.08);
}
thead th:hover{ background:var(--ink-2); }
thead th .arrow{ opacity:.5; margin-left:4px; font-size:10px; }
thead th.sorted .arrow{ opacity:1; color:#fff; }
tbody tr{ border-bottom:1px solid var(--line); cursor:pointer; }
tbody tr:hover{ background:#f9fafb; }
tbody tr.expanded{ background:#eef3f8; }
tbody td{ padding:9px 12px; vertical-align:top; font-size:13px; }
td.org{ font-weight:600; color:var(--ink); }
td.email{ font-family:var(--mono); font-size:12px; color:var(--muted); }
.industry-tags{ display:flex; flex-wrap:wrap; gap:4px; }
.industry-tags span{ font-size:11px; background:#eef1f5; border:1px solid var(--line-strong); padding:1px 6px; border-radius:9px; color:var(--slate); }
.deal-tags{ display:flex; flex-wrap:wrap; gap:4px; }
.deal-tags span{ font-size:11px; font-weight:600; background:#e7eef5; color:var(--ink); border:1px solid #c7d6e6; padding:1px 7px; border-radius:3px; }
.status-badge{ font-size:11px; font-weight:600; padding:2px 7px; border-radius:3px; background:#eee; color:#777; border:1px solid #ddd; }
.status-badge.empty{ opacity:.45; font-weight:400; }
.aum-cell{ font-family:var(--mono); font-size:12.5px; white-space:nowrap; }
.aum-value{ font-weight:600; color:var(--ink); }
.aum-value.empty{ opacity:.35; font-weight:400; font-family:var(--sans); }
.hint-inline{ font-size:11px; color:var(--muted); font-weight:400; }
tr.detail-row td{ background:#f7f9fb; padding:14px 20px 18px; border-bottom:2px solid var(--ink); }
.detail-actions{ display:flex; justify-content:flex-end; margin-bottom:10px; }
.detail-actions .btn-secondary{ padding:6px 12px; font-size:12.5px; }
.detail-grid{ display:grid; grid-template-columns: repeat(3, 1fr); gap:14px 24px; }
.detail-field label{ display:block; font-size:10.5px; text-transform:uppercase; letter-spacing:.08em; color:var(--muted); margin-bottom:3px; }
.detail-field div{ font-size:13px; color:var(--slate); white-space:pre-wrap; }
.detail-field.wide{ grid-column: 1 / -1; }
.empty-state{ text-align:center; padding:70px 20px; color:var(--muted); }
.empty-state svg{ width:40px; height:40px; opacity:.3; margin-bottom:10px; }
.load-more-wrap{ text-align:center; padding:16px; }
.load-more-btn{ background:#fff; border:1px solid var(--line-strong); padding:8px 18px; border-radius:20px; cursor:pointer; font-size:13px; color:var(--slate); }

/* ---------- Modal ---------- */
.modal-overlay{
  position:fixed; inset:0; background:rgba(15,20,30,.55);
  display:flex; align-items:center; justify-content:center;
  z-index:50; padding:24px;
}
.modal-overlay.hidden{ display:none; }
.modal{
  background:#fff; border-radius:8px; width:100%; max-width:720px;
  max-height:88vh; overflow-y:auto; box-shadow:0 20px 60px rgba(0,0,0,.35);
}
.modal-head{
  display:flex; align-items:center; justify-content:space-between;
  padding:18px 24px; border-bottom:1px solid var(--line);
  position:sticky; top:0; background:#fff;
}
.modal-head h2{ margin:0; font-size:16px; color:var(--ink); }
.modal-head button{ background:none; border:none; font-size:20px; cursor:pointer; color:var(--muted); line-height:1;}
.modal-body{ padding:20px 24px; }
.form-grid{ display:grid; grid-template-columns:1fr 1fr; gap:14px 16px; }
.form-field{ display:flex; flex-direction:column; gap:5px; }
.form-field.wide{ grid-column:1/-1; }
.form-field label{ font-size:12px; font-weight:600; color:var(--slate); }
.form-field .hint{ font-size:11px; color:var(--muted); font-weight:400; }
.form-field input, .form-field textarea{
  border:1px solid var(--line-strong); border-radius:5px; padding:8px 10px; font-size:13px;
  font-family:inherit; color:var(--ink);
}
.form-field textarea{ resize:vertical; min-height:60px; }
.form-field input:focus-visible, .form-field textarea:focus-visible{ outline:2px solid var(--focus); }
.modal-foot{
  display:flex; align-items:center; justify-content:flex-end; gap:10px;
  padding:16px 24px; border-top:1px solid var(--line);
  position:sticky; bottom:0; background:#fff;
}
.btn-secondary{ background:#fff; border:1px solid var(--line-strong); color:var(--slate); padding:9px 16px; border-radius:5px; font-size:13px; cursor:pointer; }
.btn-primary{ background:var(--ink); border:1px solid var(--ink); color:#fff; font-weight:700; padding:9px 18px; border-radius:5px; font-size:13px; cursor:pointer; }
.btn-primary:disabled{ opacity:.6; cursor:default; }
.form-error{ color:var(--rust); font-size:12.5px; margin-top:4px; min-height:16px; }
.modal-intro{ font-size:13px; color:var(--muted); line-height:1.5; margin:0 0 16px; }
.radio-row{ display:flex; flex-direction:column; gap:10px; }
.radio-option{
  display:flex; align-items:flex-start; gap:9px; font-size:13px; color:var(--slate);
  border:1px solid var(--line-strong); border-radius:6px; padding:10px 12px; cursor:pointer;
}
.radio-option:hover{ background:#fafbfc; }
.radio-option input[type="radio"]{ margin-top:3px; flex:none; accent-color:var(--ink); }
.form-field input[type="file"]{ border:1px dashed var(--line-strong); padding:14px 10px; background:#fafbfc; cursor:pointer; }
.import-summary{
  margin-top:14px; background:var(--green-bg, #e5f0e9); border:1px solid #bfe0cd;
  border-radius:6px; padding:12px 14px; font-size:13px; color:var(--green);
}
.import-summary.hidden{ display:none; }
.import-summary ul{ margin:6px 0 0; padding-left:18px; }
.toast{
  position:fixed; bottom:24px; left:50%; transform:translateX(-50%);
  background:var(--ink); color:#fff; padding:11px 20px; border-radius:6px;
  font-size:13px; box-shadow:0 8px 24px rgba(0,0,0,.3); z-index:60;
  display:flex; align-items:center; gap:8px;
}
.toast.hidden{ display:none; }
.toast .dot{ width:7px; height:7px; border-radius:50%; background:#fff; flex:none; }

@media (max-width: 860px){
  #app{ grid-template-columns: 1fr; grid-template-rows:auto auto 1fr; }
  nav.sidebar{ max-height:38vh; }
  .detail-grid{ grid-template-columns: 1fr 1fr; }
  .form-grid{ grid-template-columns: 1fr; }
  header.topbar{ flex-wrap:wrap; height:auto; padding:10px 16px; gap:10px; }
}
