/* =====================================================================
   Venture CRM — enterprise SaaS styling. Desktop-first, table-first.
   ===================================================================== */

:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --ink: #1a2233;
  --ink-soft: #5b6577;
  --ink-dim: #8a93a3;
  --line: #e3e8ef;
  --line-soft: #eef1f5;
  --brand: #1f5fd6;
  --brand-dark: #1748a8;
  --brand-soft: #e8f0fe;
  --accent: #7c3aed;
  --green: #15924d;
  --green-soft: #e3f6ec;
  --orange: #d97706;
  --orange-soft: #fdf0dd;
  --red: #d93636;
  --red-soft: #fdeaea;
  --gray: #9aa3b2;
  --shadow: 0 1px 2px rgba(20,30,55,.06), 0 4px 16px rgba(20,30,55,.06);
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

/* -------- Top bar -------- */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  color: #fff; display: grid; place-items: center; font-size: 15px;
}
.brand-title { font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-sub { font-size: 11px; color: var(--ink-dim); }
.global-search { flex: 1; max-width: 520px; }
.global-search input {
  width: 100%; padding: 9px 13px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 13px; background: #fafbfc;
}
.global-search input:focus { outline: none; border-color: var(--brand); background: #fff; }
.topbar-actions { margin-left: auto; }

/* -------- Tabs -------- */
.tabs {
  display: flex; gap: 2px; padding: 0 22px;
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 59px; z-index: 39;
}
.tab {
  border: none; background: none; padding: 12px 16px;
  font-size: 13.5px; font-weight: 500; color: var(--ink-soft);
  cursor: pointer; border-bottom: 2px solid transparent;
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

/* -------- Layout -------- */
main { padding: 20px 22px 60px; max-width: 1500px; margin: 0 auto; }
.view { animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* -------- Buttons -------- */
.btn {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 8px 14px; border-radius: 8px; font-size: 13px; font-weight: 500;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { border-color: #c9d2de; background: #fbfcfd; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { background: #b82a2a; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; margin-top: 10px; }
.btn-row.wrap { flex-wrap: wrap; }
.file-btn { cursor: pointer; }
.icon-btn {
  border: 1px solid transparent; background: none; cursor: pointer;
  padding: 4px 8px; border-radius: 6px; font-size: 13px; color: var(--ink-soft);
}
.icon-btn:hover { background: var(--line-soft); color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }

/* -------- Badges -------- */
.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.6; white-space: nowrap;
}
.prio-high { background: var(--red-soft); color: var(--red); }
.prio-medium { background: var(--orange-soft); color: var(--orange); }
.prio-low { background: var(--line-soft); color: var(--ink-soft); }

.status { background: var(--line-soft); color: var(--ink-soft); }
.st-research { background: #eef1f5; color: #5b6577; }
.st-qualified { background: #e8f0fe; color: #1f5fd6; }
.st-warm-intro-needed { background: #fdf0dd; color: #b45309; }
.st-contact-ready { background: #ede9fe; color: #6d28d9; }
.st-contacted { background: #e0f2fe; color: #0369a1; }
.st-waiting-reply { background: #fef3c7; color: #92600a; }
.st-meeting-scheduled { background: #dcfce7; color: #15803d; }
.st-due-diligence { background: #d1fae5; color: #047857; }
.st-negotiation { background: #cffafe; color: #0e7490; }
.st-passed { background: #f1f3f6; color: #8a93a3; }
.st-not-fit { background: #f1f3f6; color: #8a93a3; }
.st-closed { background: #15924d; color: #fff; }

.h-red, .badge.h-red { background: var(--red-soft); color: var(--red); }
.h-orange, .badge.h-orange { background: var(--orange-soft); color: var(--orange); }
.h-green, .badge.h-green { background: var(--green-soft); color: var(--green); }
.h-gray, .badge.h-gray { background: var(--line-soft); color: var(--ink-dim); }
.h-red-text { color: var(--red); }
.h-orange-text { color: var(--orange); }

.star { color: #e6a700; font-size: 12px; }

/* score pill */
.score-pill {
  font-weight: 700; font-size: 12px; padding: 2px 8px; border-radius: 7px;
  background: var(--line-soft); color: var(--ink-soft);
}
.score-pill .score-max { font-weight: 500; opacity: .6; font-size: 10px; }
.score-high { background: var(--green-soft); color: var(--green); }
.score-mid { background: var(--orange-soft); color: var(--orange); }
.score-low { background: var(--line-soft); color: var(--ink-dim); }

.chip {
  display: inline-block; background: var(--brand-soft); color: var(--brand-dark);
  border-radius: 6px; padding: 2px 8px; font-size: 11px; font-weight: 500; margin: 2px 3px 0 0;
}
.dim { color: var(--ink-dim); }
.small { font-size: 11px; }
.muted { color: var(--ink-soft); }
.empty { text-align: center; color: var(--ink-dim); padding: 24px; }
.empty.small { padding: 12px; }

/* -------- Cards -------- */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow);
}
.card-head { font-weight: 600; font-size: 13.5px; margin-bottom: 12px; display: flex; align-items: baseline; gap: 8px; }
.card-sub { font-weight: 400; color: var(--ink-dim); font-size: 11.5px; }

/* -------- Dashboard -------- */
.raise-banner {
  display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px;
  background: linear-gradient(135deg, #1f2c44, #233a6b); color: #fff;
  border-radius: var(--radius); padding: 14px 18px;
}
.raise-item { padding: 4px 18px 4px 0; border-right: 1px solid rgba(255,255,255,.14); }
.raise-item:last-child { border-right: none; }
.raise-label { display: block; font-size: 11px; opacity: .7; text-transform: uppercase; letter-spacing: .04em; }
.raise-val { font-size: 18px; font-weight: 700; }
.raise-val small { font-size: 11px; opacity: .6; font-weight: 500; }
.raise-val.warn { color: #ffb4b4; }
.raise-val.ok { color: #a9f0c4; }

.kpi-grid {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 18px;
}
.kpi {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 13px 15px; box-shadow: var(--shadow);
}
.kpi-val { font-size: 23px; font-weight: 700; letter-spacing: -.02em; }
.kpi-label { font-size: 11.5px; color: var(--ink-soft); margin-top: 2px; }
.kpi.accent .kpi-val { color: var(--accent); }
.kpi.region .kpi-val { color: var(--brand); }
.kpi.warn { border-color: #f3d9b0; } .kpi.warn .kpi-val { color: var(--orange); }
.kpi.danger { border-color: #f3c2c2; } .kpi.danger .kpi-val { color: var(--red); }
.kpi.muted .kpi-val { color: var(--ink-dim); }

.dash-cols { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }

.mini-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini-table th { text-align: left; color: var(--ink-dim); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .03em; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.mini-table td { padding: 9px 8px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.mini-table tr.clickable:hover { background: #f7f9fc; cursor: pointer; }
.reasons { line-height: 1.7; }

/* bar charts */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 28px; align-items: center; gap: 9px; font-size: 12px; }
.bar-label { color: var(--ink-soft); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-track { background: var(--line-soft); border-radius: 6px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--brand); }
.bar-fill.region { background: var(--accent); }
.bar-val { text-align: right; font-weight: 600; color: var(--ink-soft); }

.exec-flags { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.flag { display: flex; justify-content: space-between; padding: 8px 11px; border-radius: 8px;
  background: var(--line-soft); font-size: 12px; color: var(--ink-soft); }
.flag.on { background: var(--orange-soft); color: var(--orange); font-weight: 600; }
.flag b { font-size: 14px; }

/* -------- Filter bar -------- */
.filterbar {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  margin-bottom: 14px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
}
.filterbar select {
  padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 12.5px; background: #fff; color: var(--ink); cursor: pointer;
}
.minscore { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ink-soft); }
.minscore input[type=range] { width: 110px; }
.minscore span { font-weight: 600; min-width: 16px; }
.filterbar .btn { margin-left: auto; }

/* -------- VC Table -------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); }
.vc-table { width: 100%; border-collapse: collapse; font-size: 13px; min-width: 1100px; }
.vc-table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--ink-dim);
  text-transform: uppercase; letter-spacing: .03em; padding: 11px 12px;
  border-bottom: 1px solid var(--line); background: #fafbfc; position: sticky; top: 0;
}
.vc-table td { padding: 10px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.vc-table tbody tr:hover { background: #f7f9fc; }
.vc-table tr.row-high { background: #fffdf5; }
.vc-table tr.row-high:hover { background: #fff8e8; }
.vc-table .clickable { cursor: pointer; }
.vc-table .focus { max-width: 200px; color: var(--ink-soft); }
.row-actions { white-space: nowrap; }
.table-foot { padding: 10px 4px; color: var(--ink-dim); font-size: 12px; }

/* -------- Kanban -------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 14px; align-items: flex-start; }
.kcol {
  flex: 0 0 250px; background: #eef1f6; border-radius: var(--radius);
  display: flex; flex-direction: column; max-height: calc(100vh - 220px);
}
.kcol-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 11px 13px; font-size: 12.5px; font-weight: 600; color: var(--ink-soft);
  position: sticky; top: 0; background: #eef1f6; border-radius: var(--radius) var(--radius) 0 0;
}
.kcount { background: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; color: var(--ink-soft); }
.kcol-body { padding: 4px 9px 12px; overflow-y: auto; flex: 1; min-height: 60px; }
.kcol-body.drop-hover { background: #e1e8f3; border-radius: 8px; outline: 2px dashed #b9c6dd; }
.kcard {
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px 11px; margin-bottom: 8px; cursor: grab; box-shadow: 0 1px 2px rgba(20,30,55,.05);
}
.kcard:hover { border-color: #c9d2de; box-shadow: var(--shadow); }
.kcard.dragging { opacity: .5; }
.kcard-high { border-left: 3px solid #e6a700; }
.kcard-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kcard-top strong { font-size: 13px; line-height: 1.3; }
.kcard-meta { font-size: 11.5px; color: var(--ink-soft); margin: 5px 0 8px; display: flex; gap: 5px; }
.kcard-meta .dot { color: var(--ink-dim); }
.kcard-foot { display: flex; justify-content: space-between; align-items: center; }
.kcard-next { font-size: 10.5px; padding: 2px 7px; border-radius: 6px; font-weight: 600; }

/* -------- Follow-up -------- */
.fu-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.fu-card { padding: 14px 16px; }
.fu-list { list-style: none; margin: 0; padding: 0; }
.fu-item {
  display: flex; justify-content: space-between; gap: 10px; padding: 9px 0;
  border-bottom: 1px solid var(--line-soft); cursor: pointer;
}
.fu-item:last-child { border-bottom: none; }
.fu-item:hover { background: #f7f9fc; }
.fu-main { min-width: 0; }
.fu-side { text-align: right; white-space: nowrap; font-size: 12px; color: var(--ink-soft); }

/* -------- Import view -------- */
.import-view { display: grid; gap: 16px; max-width: 900px; }
.import-view textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; resize: vertical;
}
.import-result { margin-top: 12px; }
.ok-box { background: var(--green-soft); color: var(--green); padding: 10px 13px; border-radius: 8px; font-size: 13px; }
.err-box { background: var(--red-soft); color: var(--red); padding: 10px 13px; border-radius: 8px; font-size: 13px; }
.danger-card { border-color: #f3d2d2; }

/* -------- Modals -------- */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(20,28,46,.45);
  display: grid; place-items: center; z-index: 100; padding: 24px; animation: fade .15s ease;
}
.modal {
  background: var(--surface); border-radius: 14px; box-shadow: 0 20px 60px rgba(20,30,55,.3);
  width: 100%; max-height: 90vh; overflow: hidden; display: flex; flex-direction: column;
}
.detail-modal { max-width: 980px; }
.form-modal { max-width: 860px; }
.detail-head {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.detail-title { font-size: 17px; font-weight: 700; }
.detail-head-actions { display: flex; align-items: center; gap: 8px; }
.detail-body { display: grid; grid-template-columns: 1.1fr 1fr; gap: 0; overflow: hidden; }
.detail-left { padding: 16px 20px; overflow-y: auto; border-right: 1px solid var(--line); }
.detail-right { padding: 16px 20px; overflow-y: auto; background: #fafbfc; }
.detail-left, .detail-right { max-height: calc(90vh - 70px); }
.d-section { margin-bottom: 18px; }
.d-section h4 { margin: 0 0 9px; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-dim); }
.badges-row { display: flex; gap: 6px; flex-wrap: wrap; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 5px 0; border-bottom: 1px dashed var(--line-soft); font-size: 13px; }
.kv span { color: var(--ink-soft); flex: 0 0 auto; }
.kv b { text-align: right; font-weight: 600; }
.notes-val { font-weight: 400; color: var(--ink-soft); text-align: right; }

.score-breakdown { margin: 10px 0; }
.sb-row { display: grid; grid-template-columns: 64px 1fr 42px; align-items: center; gap: 9px; margin: 4px 0; font-size: 12px; }
.sb-label { color: var(--ink-soft); }
.sb-track { background: var(--line-soft); height: 8px; border-radius: 5px; overflow: hidden; }
.sb-fill { height: 100%; background: linear-gradient(90deg, var(--brand), var(--accent)); border-radius: 5px; }
.sb-val { text-align: right; color: var(--ink-soft); font-weight: 600; }
.suggest-box { background: var(--brand-soft); color: var(--brand-dark); padding: 9px 12px; border-radius: 8px; font-size: 12.5px; margin-top: 8px; }
.touch-stats { display: flex; gap: 18px; font-size: 12.5px; color: var(--ink-soft); margin: 10px 0; }

.log-form { display: grid; grid-template-columns: 130px 1fr auto; gap: 7px; }
.log-form input, .log-form select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font-size: 12.5px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 7px 0; }
.tl-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--brand); margin-top: 5px; flex: 0 0 auto; }
.tl-body { font-size: 12.5px; }
.tl-head { display: flex; gap: 8px; align-items: baseline; }

/* -------- Form -------- */
.vc-form { padding: 16px 20px; overflow-y: auto; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 11px 14px; }
.f-field { display: flex; flex-direction: column; gap: 4px; }
.f-field.full { grid-column: 1 / -1; }
.vc-form > .f-field.full { margin-top: 11px; }
.f-label { font-size: 11.5px; color: var(--ink-soft); font-weight: 500; }
.f-field input, .f-field select, .f-field textarea {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 7px; font-size: 13px;
  font-family: inherit; background: #fff; width: 100%;
}
.f-field input:focus, .f-field select:focus, .f-field textarea:focus { outline: none; border-color: var(--brand); }
.form-foot {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
}
.live-score { font-size: 13px; color: var(--ink-soft); }
.live-score span { font-weight: 700; color: var(--brand); font-size: 15px; }

/* -------- Toast -------- */
.toast-root { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 200; }
.toast {
  background: #1f2c44; color: #fff; padding: 11px 18px; border-radius: 9px;
  font-size: 13px; box-shadow: 0 8px 28px rgba(20,30,55,.3); animation: fade .2s ease;
}

/* -------- Responsive-ish -------- */
@media (max-width: 1200px) {
  .kpi-grid { grid-template-columns: repeat(4, 1fr); }
  .dash-cols { grid-template-columns: 1fr; }
  .fu-grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .detail-body { grid-template-columns: 1fr; }
  .detail-left { border-right: none; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .fu-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
