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

:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e6ea;
  --primary: #1a56db;
  --primary-hover: #1345b5;
  --danger: #e02424;
  --success: #057a55;
  --warning: #c27803;
  --text: #111827;
  --muted: #6b7280;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.1);
}

body { font-family: 'Inter', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 14px; overflow-x: hidden; }

/* Header */
header { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; width: 100%; }
.header-inner { max-width: 1400px; margin: auto; padding: 0 24px; min-height: 56px; display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
h1 { font-size: 18px; font-weight: 700; white-space: nowrap; }
h1 .by { font-weight: 400; color: var(--muted); font-size: 14px; }
nav { display: flex; gap: 4px; flex-wrap: wrap; }
.nav-btn { background: none; border: none; padding: 6px 14px; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--muted); transition: all .15s; }
.nav-btn:hover, .nav-btn.active { background: var(--primary); color: #fff; }

/* Main */
main { max-width: 1400px; margin: 0 auto; padding: 24px; }
.view { display: none; }
.view.active { display: block; }

/* Toolbar */
.toolbar { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.toolbar h2 { font-size: 20px; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* Buttons */
.btn { padding: 7px 14px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-size: 13px; transition: all .15s; }
.btn:hover { border-color: #adb5bd; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Tables */
#startups-table-wrap,
#investors-table-wrap,
#vc-funds-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th { background: #f1f3f5; font-weight: 600; text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: #f8f9fa; }

/* Score pills */
.score { display: inline-block; min-width: 28px; text-align: center; padding: 2px 6px; border-radius: 12px; font-weight: 600; font-size: 12px; }
.score-high { background: #d1fae5; color: #065f46; }
.score-mid  { background: #fef3c7; color: #92400e; }
.score-low  { background: #fee2e2; color: #991b1b; }
.score-none { background: #f3f4f6; color: #9ca3af; }

/* Match cards */
#matches-list { display: flex; flex-direction: column; gap: 12px; }
.match-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 20px; box-shadow: var(--shadow); }
.match-card-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.match-card-title { font-weight: 700; font-size: 15px; }
.match-card-subtitle { color: var(--muted); font-size: 13px; margin-top: 2px; }
.match-card-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 12px; font-weight: 500; }
.badge-pending  { background: #e0f2fe; color: #075985; }
.badge-approved { background: #d1fae5; color: #065f46; }
.badge-sent     { background: #ede9fe; color: #4c1d95; }
.badge-rejected { background: #f3f4f6; color: #6b7280; }
.badge-queued   { background: #fef3c7; color: #92400e; }
.match-reasoning { margin-top: 8px; font-size: 13px; color: var(--muted); }
.match-card-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Grouped match view */
.startup-group {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  overflow: hidden;
}

.startup-group-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
  gap: 16px;
}

.startup-group-info {
  flex: 1;
  min-width: 0;
}

.match-table {
  width: 100%;
  border-collapse: collapse;
}

.match-table td {
  padding: 10px 18px;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: top;
}

.match-table tr:last-child td {
  border-bottom: none;
}

.match-table tr:hover td {
  background: #fafafa;
}

/* Select */
select { padding: 6px 10px; border-radius: var(--radius); border: 1px solid var(--border); font-size: 13px; background: var(--surface); }

/* Modal */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 500; display: flex; align-items: center; justify-content: center; }
.modal.hidden { display: none; }
.modal-box { background: var(--surface); border-radius: 12px; width: 640px; max-width: 95vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 32px rgba(0,0,0,.2); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; }
.btn-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 10px; }
.modal-body label { font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.modal-body input, .modal-body textarea { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; font-family: inherit; resize: vertical; }
.modal-body textarea { line-height: 1.6; }
.modal-footer { padding: 16px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* Toast */
.toast { position: fixed; bottom: 24px; right: 24px; background: #111827; color: #fff; padding: 10px 18px; border-radius: 8px; font-size: 13px; z-index: 999; box-shadow: 0 4px 12px rgba(0,0,0,.3); transition: opacity .3s; }
.toast.hidden { display: none; }

/* Spinner */
.spinner { display: inline-block; width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; vertical-align: middle; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Empty state */
.empty { text-align: center; padding: 48px; color: var(--muted); }

/* Sortable column headers */
th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
th.sortable:hover { color: var(--primary); }
th.sortable::after { content: " ⇅"; opacity: .35; font-size: 11px; }
th.sort-asc::after  { content: " ↑"; opacity: 1; color: var(--primary); }
th.sort-desc::after { content: " ↓"; opacity: 1; color: var(--primary); }
