:root {
  --bg: #0b1020;
  --surface: #131a33;
  --surface-2: #1b2547;
  --border: #2a3563;
  --text: #e8ecff;
  --muted: #9aa3c7;
  --accent: #6366f1;
  --accent-2: #a78bfa;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; margin: 0; -webkit-text-size-adjust: 100%; }
a { color: var(--accent-2); }
a:hover { color: #fff; }
code { background: rgba(255,255,255,0.07); padding: 1px 6px; border-radius: 6px; font-size: 13px; word-break: break-word; }

.page { max-width: 960px; margin: 0 auto; padding: 32px 20px 80px; }
.page.narrow { max-width: 460px; }

.header { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { color: var(--muted); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; }
h1 { margin: 4px 0 0; font-size: 28px; font-weight: 700; letter-spacing: -0.02em; background: linear-gradient(90deg, #fff, #c7d2fe); -webkit-background-clip: text; background-clip: text; color: transparent; }
h2 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
h3 { margin: 0 0 8px; font-size: 15px; font-weight: 600; color: var(--accent-2); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; margin-bottom: 16px; }
.card.empty { color: var(--muted); text-align: center; }

.muted { color: var(--muted); font-size: 13px; }
.error-text { color: var(--bad); }
.error { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.35); color: #fecaca; padding: 8px 12px; border-radius: 10px; font-size: 13px; }

.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font-size: 13px; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: rgba(248,113,113,0.12); border-color: rgba(248,113,113,0.4); color: #fecaca; }
.btn.danger:hover { background: rgba(248,113,113,0.2); }
.btn.ghost { background: transparent; }

.stack { display: flex; flex-direction: column; gap: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
input[type="password"], input[type="text"], input[type="file"] { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 16px; width: 100%; }
input[type="file"] { padding: 8px; }
input:focus { outline: none; border-color: var(--accent); }

.board-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 14px; color: var(--muted); font-size: 13px; gap: 12px; flex-wrap: wrap; }
.board { width: 100%; border-collapse: collapse; }
.board th, .board td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.board th { font-size: 11px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 500; }
.board tr:last-child td { border-bottom: 0; }
.board tbody tr:hover { background: rgba(99,102,241,0.07); }
.w-rank { width: 80px; }
.w-evals { width: 120px; }
.w-score { width: 120px; text-align: right; }
.board td.score { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; font-size: 16px; }
.board td.rank { font-variant-numeric: tabular-nums; font-weight: 700; font-size: 16px; color: var(--muted); }
.rank-1 { color: #fde68a !important; }
.rank-2 { color: #e5e7eb !important; }
.rank-3 { color: #fdba74 !important; }
.board.mini th, .board.mini td { padding: 8px 10px; font-size: 13px; }

dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; width: min(720px, calc(100vw - 24px)); max-height: 86vh; overflow: auto; }
dialog::backdrop { background: rgba(0,0,0,0.6); }
.detail-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; gap: 12px; }
.detail-head h2 { font-size: 22px; }
.eval-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-top: 12px; }
.eval-head { display: flex; justify-content: space-between; margin-bottom: 10px; gap: 8px; flex-wrap: wrap; }
.section { margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border); }
.section:first-of-type { border-top: 0; padding-top: 0; }
.section-head { display: flex; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--accent-2); margin-bottom: 6px; gap: 8px; }
.pillar { padding: 6px 0; }
.pillar-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.pillar-comment { color: var(--muted); font-size: 13px; font-style: italic; margin-top: 4px; padding-left: 8px; border-left: 2px solid var(--border); }
.level-chip { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; min-width: 26px; text-align: center; display: inline-block; }
.level-1 { background: rgba(248,113,113,0.18); color: #fecaca; }
.level-2 { background: rgba(251,191,36,0.15); color: #fcd34d; }
.level-3 { background: rgba(148,163,184,0.18); color: #e2e8f0; }
.level-4 { background: rgba(99,102,241,0.2); color: #c7d2fe; }
.level-5 { background: rgba(52,211,153,0.18); color: #6ee7b7; }
.sheet-list { padding-left: 18px; margin: 8px 0; }
.sheet-list li { margin: 4px 0; }

.name-input { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: 8px; font-size: 14px; width: 100%; max-width: 280px; }
.name-input:focus { outline: none; border-color: var(--accent); }
.merge-select { background: var(--surface-2); border: 1px solid var(--border); color: var(--text); padding: 7px 10px; border-radius: 8px; font-size: 13px; max-width: 200px; }
.actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* Methodology page */
.level-legend { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin: 10px 0 14px; font-size: 13px; }
.level-legend .muted { margin-right: 8px; }
.steps { padding-left: 22px; margin: 8px 0; }
.steps li { margin: 14px 0; }
.formula { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-top: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: #c7d2fe; }
.example-block { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.example-evaluator { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 14px; }
.example-evaluator .formula { font-size: 12px; }
.overall-result { margin-top: 16px; padding: 14px; border-radius: 10px; background: linear-gradient(135deg, rgba(99,102,241,0.18), rgba(167,139,250,0.18)); border: 1px solid rgba(167,139,250,0.35); text-align: center; }
.big-score { font-size: 26px; color: #fff; }
.bullets { padding-left: 18px; margin: 8px 0; }
.bullets li { margin: 6px 0; color: var(--muted); }
.bullets li strong { color: var(--text); }

/* === Mobile === */
@media (max-width: 720px) {
  .page { padding: 18px 14px 64px; }
  .header { align-items: flex-start; gap: 12px; margin-bottom: 18px; }
  h1 { font-size: 22px; }
  h2 { font-size: 16px; }
  .header-actions { width: 100%; gap: 6px; }
  .header-actions .btn { padding: 7px 10px; font-size: 12px; flex: 1 1 auto; justify-content: center; }
  .card { padding: 16px; border-radius: 12px; }

  /* Leaderboard table: compact on mobile, hide w-evals column */
  .board th, .board td { padding: 10px 8px; }
  .w-evals { display: none; }
  .w-rank { width: 48px; }
  .w-score { width: 70px; }
  .board td.score { font-size: 15px; }
  .board td.rank { font-size: 15px; }
  .board th { font-size: 10px; letter-spacing: 0.08em; }

  /* Methodology example: stack the two evaluators */
  .example-block { grid-template-columns: 1fr; }

  /* Drill-down dialog full-screen-ish */
  dialog { padding: 18px; width: calc(100vw - 16px); max-height: 92vh; border-radius: 12px; }
  .detail-head h2 { font-size: 18px; }
  .eval-head strong { font-size: 14px; }
  .pillar-head span:first-child { font-size: 14px; line-height: 1.3; }

  /* Manage page: turn the rename/merge table into stacked cards per startup */
  .manage-table { display: none; }
  .manage-cards { display: flex; flex-direction: column; gap: 10px; }
  .manage-card { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
  .manage-card .mc-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
  .manage-card .mc-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
  .manage-card .mc-row { display: flex; gap: 6px; align-items: center; }
  .manage-card .mc-row > * { flex: 1; }
  .manage-card .name-input, .manage-card .merge-select { max-width: none; font-size: 14px; }
  .formula { font-size: 12px; padding: 8px 10px; word-break: break-word; }
}

@media (min-width: 721px) {
  .manage-cards { display: none; }
}
