:root {
  --bull-navy: #0b1f63;
  --bull-navy-2: #132a7a;
  --bull-orange: #ff5a36;
  --bull-orange-2: #ff7a56;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --bg: #f7f8fb;
  --card: #ffffff;
  --green: #22a06b;
  --amber: #e8a43a;
  --red: #dc3545;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 4px 12px rgba(15, 23, 42, 0.06);
  --radius: 10px;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo { height: 34px; width: auto; display: block; }
.brand-text { line-height: 1.15; }
.brand-title { font-weight: 700; color: var(--bull-navy); font-size: 16px; letter-spacing: 0.2px; }
.brand-sub { color: var(--muted); font-size: 12px; }

.header-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

.btn {
  border: 1px solid transparent;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #f1f3f8;
  color: var(--ink);
  transition: transform 0.05s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--bull-navy); color: #fff; }
.btn-primary:hover { background: var(--bull-navy-2); }
.btn-accent { background: var(--bull-orange); color: #fff; }
.btn-accent:hover { background: var(--bull-orange-2); }
.btn-ghost { background: transparent; color: var(--bull-navy); border-color: var(--line); }
.btn-danger { background: #fdecec; color: var(--red); border-color: #f7c7c7; padding: 4px 8px; font-size: 12px; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: transparent;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.filter-input {
  flex: 1;
  min-width: 220px;
  max-width: 420px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}
.filter-input:focus { outline: 2px solid rgba(11,31,99,0.2); border-color: var(--bull-navy); }

.legend { display: flex; gap: 16px; color: var(--muted); font-size: 12px; flex-wrap: wrap; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.dot-strong { background: var(--green); }
.dot-mid { background: var(--amber); }
.dot-weak { background: var(--red); }

.table-wrap {
  padding: 16px 24px 24px;
  overflow-x: auto;
}

.inv-table {
  width: 100%;
  min-width: 1200px;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.inv-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: #fff;
  background: var(--bull-navy);
  padding: 10px 10px;
  white-space: nowrap;
  user-select: none;
  position: sticky;
  top: 0;
}
.inv-table thead th.sortable { cursor: pointer; }
.inv-table thead th.sortable:hover { background: var(--bull-navy-2); }
.inv-table thead th .sort-ind { font-size: 10px; opacity: 0.7; margin-left: 4px; }
.inv-table thead th .inv-mark {
  display: inline-block;
  margin-left: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: var(--bull-orange);
  padding: 1px 5px;
  border-radius: 999px;
  line-height: 1;
  vertical-align: middle;
}

.inv-table tbody td {
  padding: 8px 10px;
  border-top: 1px solid var(--line);
  vertical-align: middle;
  font-size: 13px;
}
.inv-table tbody tr:hover { background: #fafbff; }

.name-input {
  width: 100%;
  min-width: 160px;
  border: 1px solid transparent;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  background: transparent;
}
.name-input:hover { border-color: var(--line); background: #fff; }
.name-input:focus { outline: none; border-color: var(--bull-navy); background: #fff; }

.phase-select, .rating-select {
  border: 1px solid var(--line);
  padding: 5px 6px;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
}
.rating-select { width: 72px; text-align: center; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.phase-discovery { background: #eef1f9; color: var(--bull-navy); }
.phase-scoping   { background: #fff1e9; color: #b34a1f; }
.phase-funded    { background: #e6f6ee; color: #146c43; }
.phase-parked    { background: #f0f2f5; color: #475569; }

.score-cell { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.score-pct  { color: var(--muted); font-weight: 500; font-size: 11px; margin-left: 6px; }
.status-strong { color: var(--green); }
.status-mid    { color: var(--amber); }
.status-weak   { color: var(--red); }

.empty-row td {
  text-align: center;
  color: var(--muted);
  padding: 28px 10px;
}

.app-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 24px;
  border-top: 1px solid var(--line);
  background: #fff;
  font-size: 12px;
  color: var(--muted);
}
.app-footer .spacer { flex: 1; }
.muted { color: var(--muted); }

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(11,31,99,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 20px;
}
.modal.hidden { display: none; }
.modal-card {
  background: #fff;
  border-radius: 12px;
  width: 640px;
  max-width: 100%;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(11,31,99,0.25);
}
.modal-card.small { width: 420px; }
.modal-card.wide  { width: 820px; max-height: 88vh; }
.modal-head {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.modal-head h3 { margin: 0; font-size: 15px; color: var(--bull-navy); }
.modal-close {
  margin-left: auto;
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 14px 16px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input {
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}
.field input:focus { outline: 2px solid rgba(11,31,99,0.2); border-color: var(--bull-navy); }

.history-list { display: flex; flex-direction: column; gap: 6px; }
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}
.history-item:hover { border-color: var(--bull-navy); }
.history-item .h-label { font-weight: 600; color: var(--ink); }
.history-item .h-time  { color: var(--muted); font-size: 12px; }
.history-item .h-actions { margin-left: auto; display: flex; gap: 6px; }
.history-empty { color: var(--muted); text-align: center; padding: 20px; }

/* Scoring guide */
.guide-intro {
  margin: 0 0 14px;
  padding: 12px 14px;
  background: #f1f3f8;
  border-left: 4px solid var(--bull-navy);
  border-radius: 6px;
  font-size: 13px;
  color: var(--ink);
}
.inv-mark-inline {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  background: var(--bull-orange);
  padding: 1px 6px;
  border-radius: 999px;
  line-height: 1.4;
}
.strength-legend {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}
.strength-legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 13px;
}
.guide-list { display: flex; flex-direction: column; gap: 10px; }
.guide-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fff;
}
.guide-item.is-inverted { border-left: 4px solid var(--bull-orange); }
.guide-head { display: flex; gap: 12px; align-items: flex-start; }
.guide-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bull-navy);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 2px;
}
.guide-title {
  font-weight: 700;
  color: var(--bull-navy);
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.inv-pill {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  color: #fff;
  background: var(--bull-orange);
  padding: 2px 7px;
  border-radius: 999px;
}
.guide-q { color: var(--muted); font-size: 12px; font-style: italic; margin-top: 2px; }
.guide-desc { margin: 10px 0 12px; font-size: 13px; color: var(--ink); }
.guide-scale { display: flex; flex-direction: column; gap: 6px; }
.scale-row {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 10px;
  align-items: start;
  font-size: 12.5px;
  color: var(--ink);
}
.scale-tag {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 11px;
  text-align: center;
  letter-spacing: 0.2px;
}
.tag-high { background: #e6f6ee; color: #146c43; }
.tag-med  { background: #fff3e0; color: #b34a1f; }
.tag-low  { background: #fdecec; color: var(--red); }

.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bull-navy);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; }

@media (max-width: 760px) {
  .header-actions { width: 100%; }
  .brand-sub { display: none; }
}
