:root {
  --bg: #0f1216;
  --panel: #171b22;
  --panel-2: #1e2430;
  --panel-3: #232a38;
  --border: #2a313d;
  --text: #e6e9ee;
  --muted: #949cab;
  --accent: #3b82f6;
  --accent-hover: #2f6fe0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.45), 0 1px 2px rgba(0, 0, 0, 0.35);

  --flag-WINNER: #f5b301;
  --flag-FINALIST: #a78bfa;
  --flag-GOOD: #34d399;
  --flag-MED: #fbbf24;
  --flag-BAD: #f87171;
  --flag-DISQUALIFIED: #94a3b8;
  --flag-none: #3a4150;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}

#app { height: 100%; }
.loading { padding: 40px; color: var(--muted); }

a { color: var(--accent); }

::selection { background: rgba(59, 130, 246, 0.35); }

/* ---------- Dataset picker ---------- */
.picker {
  max-width: 780px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.picker-head { display: flex; align-items: baseline; gap: 12px; }
.picker-head h1 { flex: 1; }
.picker h1 { font-size: 26px; margin: 0 0 4px; }
.picker .sub { color: var(--muted); margin: 0 0 32px; }

/* login */
.login { max-width: 380px; margin: 0 auto; padding: 84px 24px; }
.login h1 { font-size: 24px; margin: 0 0 4px; }
.login .sub { color: var(--muted); margin: 0 0 24px; }
.login-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); padding: 22px; display: flex; flex-direction: column; gap: 12px;
}
.login-input {
  padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel-2); color: var(--text); font-size: 15px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 20px 22px;
  margin-bottom: 22px;
}
.card h2 { font-size: 15px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 14px; }

.new-form { display: flex; gap: 10px; flex-wrap: wrap; }
.new-form input[type="text"] {
  flex: 1 1 320px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: var(--panel-2);
  color: var(--text);
}
.new-form .hint { flex-basis: 100%; color: var(--muted); font-size: 13px; margin-top: 4px; }

input::placeholder, textarea::placeholder { color: #6b7482; }
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

button {
  font: inherit;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 16px;
  transition: background .12s, border-color .12s;
}
button:hover { background: var(--panel-3); }
button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: .6; cursor: default; }

.ds-list { list-style: none; margin: 0; padding: 0; }
.ds-item {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 12px; border-radius: 10px; cursor: pointer;
  border: 1px solid transparent;
}
.ds-item:hover { background: var(--panel-2); border-color: var(--border); }
.ds-item .ds-name { font-weight: 600; }
.ds-item .ds-meta { color: var(--muted); font-size: 13px; }
.ds-item .grow { flex: 1; }
.mini-flags { display: flex; gap: 6px; }
.mini-flag { font-size: 11px; padding: 2px 7px; border-radius: 20px; color: #0f1216; font-weight: 700; }
.empty { color: var(--muted); font-style: italic; }

.err { color: var(--flag-BAD); margin-top: 10px; font-size: 14px; }

/* ---------- Review layout ---------- */
.review { display: grid; grid-template-columns: 360px 1fr; height: 100%; }

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}
.sidebar-head { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sidebar-head .top { display: flex; align-items: center; gap: 8px; }
.sidebar-head h1 { font-size: 16px; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: none; color: var(--accent); padding: 4px 4px; white-space: nowrap; }
.link-btn:hover { background: none; text-decoration: underline; }
.save-btn { padding: 6px 16px; }
.save-btn:disabled { opacity: 1; background: rgba(52, 211, 153, 0.14); color: var(--flag-GOOD); border-color: rgba(52, 211, 153, 0.35); }

.save-state { font-size: 12px; color: var(--muted); margin-top: 6px; height: 16px; }
.save-state.dirty { color: var(--flag-MED); }
.save-state.saving { color: var(--muted); }
.save-state.saved { color: var(--flag-GOOD); }

.search { margin-top: 10px; width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: var(--panel-2); color: var(--text); }
.legend { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 10px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; background: var(--flag-none); }

/* filter chips */
.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.fchip {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  background: var(--panel-2); border: 1px solid var(--border); color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.fchip:hover { background: var(--panel-3); }
.fchip.active { color: #0f1216; font-weight: 700; border-color: var(--accent); background: var(--accent); }

/* badges */
.badge {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 4px;
  letter-spacing: .03em; white-space: nowrap; line-height: 1.5;
}
.badge.us { background: rgba(52, 211, 153, 0.16); color: var(--flag-GOOD); }
.badge.intl { background: rgba(148, 163, 184, 0.16); color: #9aa3b2; }
.badge.warn { background: rgba(248, 113, 113, 0.18); color: var(--flag-BAD); }

.cand-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; flex: 1; }
.cand {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px; cursor: pointer;
  border: 1px solid transparent; user-select: none;
}
.cand:hover { background: var(--panel-2); }
.cand.selected { background: var(--panel-3); border-color: #34405a; }
.cand.dragging { opacity: .4; }
.cand .rank { width: 22px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; font-size: 13px; }
.cand .grip { color: #5b6472; cursor: grab; font-size: 15px; line-height: 1; }
.cand .cand-main { flex: 1; overflow: hidden; }
.cand .cand-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cand .cand-sub { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; overflow: hidden; }
.cand .cand-sub .cand-email { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cand .cand-sub .badge { font-size: 9px; padding: 1px 5px; flex: none; }
.cand .flagdot { width: 12px; height: 12px; border-radius: 50%; flex: none; background: var(--flag-none); }

/* ---------- Detail ---------- */
.detail { overflow-y: auto; height: 100vh; padding: 28px 34px 80px; background: var(--bg); }
.detail-empty { color: var(--muted); padding: 60px; text-align: center; }
.detail h1 { margin: 0 0 2px; font-size: 24px; }
.detail .email { color: var(--muted); margin-bottom: 18px; }
.detail .email a { text-decoration: none; }
.detail .badges { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 18px; }
.detail .badge { font-size: 12px; padding: 3px 10px; border-radius: 6px; }

.flagbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.flagbtn {
  padding: 7px 14px; border-radius: 20px; font-weight: 600; font-size: 13px;
  border: 2px solid var(--border); background: var(--panel-2); color: var(--muted);
}
.flagbtn:hover { background: var(--panel-3); }
.flagbtn.active { color: #0f1216; border-color: transparent; }
.flagbtn.active.WINNER { background: var(--flag-WINNER); }
.flagbtn.active.FINALIST { background: var(--flag-FINALIST); }
.flagbtn.active.GOOD { background: var(--flag-GOOD); }
.flagbtn.active.MED { background: var(--flag-MED); }
.flagbtn.active.BAD { background: var(--flag-BAD); }
.flagbtn.active.DISQUALIFIED { background: var(--flag-DISQUALIFIED); }
.flagbtn.clear { border-style: dashed; }

.notes-wrap { margin-bottom: 26px; }
.notes-wrap label { display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.notes {
  width: 100%; min-height: 120px; resize: vertical;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  font: inherit; line-height: 1.5; color: var(--text);
  background: var(--panel-2);
}

.qa { border-top: 1px solid var(--border); padding: 16px 0; }
.qa:last-child { border-bottom: 1px solid var(--border); }
.qa .q { font-weight: 600; color: var(--muted); font-size: 13px; margin-bottom: 6px; }
.qa .a { white-space: pre-wrap; line-height: 1.55; word-break: break-word; }
.qa .a.empty { color: #5b6472; font-style: italic; }
.qa .a a { word-break: break-all; }

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #2f3846; border-radius: 8px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: #3b4656; }
