/* Palette matches the main ai-search-is dashboard's Candidate Pool voting
   screen (dashboard/index.html: #vote-overlay.theme-light) so experts see
   the same look whether they vote from the dashboard or this standalone
   app. */
:root {
  --bg: #f4f6fb;
  --card: #ffffff;
  --panel-2: #eef1f7;
  --border: #d5dbe8;
  --text: #1c2434;
  --muted: #5a6478;
  --primary: #3b6fd8;
  --primary-dark: #2f5cc0;
  --danger: #dc2626;
  --ok: #059669;
  --warn: #d97706;
  font-family: -apple-system, "Segoe UI", "Noto Sans Thai", Sarabun, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

header.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}

header.topbar a { color: var(--text); text-decoration: none; font-weight: 600; }
header.topbar .who { color: var(--muted); font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 16px;
}

h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 18px; margin: 0 0 12px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.page-head p { margin: 0; }

label { display: block; font-size: 14px; margin-bottom: 6px; color: var(--muted); }

input[type=text], input[type=password], textarea, select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 15px;
  margin-bottom: 14px;
  font-family: inherit;
}

textarea { min-height: 60px; resize: vertical; }

.icon-chevron { vertical-align: -2px; flex-shrink: 0; }

button, .btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 9px 16px;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  font-family: inherit;
}
button:hover, .btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e5e7eb; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.warn { background: var(--warn); }
.btn.small { padding: 5px 10px; font-size: 12px; }
button:disabled, .btn:disabled { opacity: .5; cursor: not-allowed; }

.error { color: var(--danger); font-size: 14px; margin-bottom: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.active { background: #dcfce7; color: var(--ok); }
.badge.archived { background: #f3f4f6; color: var(--muted); }
.badge.done { background: #dcfce7; color: var(--ok); }
.badge.partial { background: #fef3c7; color: var(--warn); }
.badge.none { background: #f3f4f6; color: var(--muted); }

.query-list a { text-decoration: none; color: var(--text); }
.query-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.readonly-note {
  background: #fff8e6;
  border: 1px solid #f0d48a;
  color: #7a5a12;
  padding: 10px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 14px;
}

.banner {
  background: #fff8e6;
  border: 1px solid #f0d48a;
  color: #7a5a12;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}

.nav-row { display: flex; justify-content: space-between; margin-top: 16px; }

.checkbox-row { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.checkbox-row label { margin: 0; color: var(--text); }

.expert-list { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 12px; }
.expert-list label { display: flex; align-items: center; gap: 4px; margin: 0; font-size: 13px; color: var(--text); }

/* ------- Candidate voting screen (mirrors dashboard/index.html #vote-overlay) ------- */

.vote-sticky {
  position: sticky;
  top: 0;
  z-index: 8;
  background: var(--bg);
  padding: 4px 0 12px;
  margin-bottom: 4px;
}

.vote-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 10px;
  font-size: 12px;
  color: var(--muted);
}
.vote-progress .track { flex: 1; height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.vote-progress .fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .2s; }

.vote-query-card {
  /* Intentional green tint, matches dashboard/index.html's #vote-overlay
     .vote-query-card — a literal rgba (not a theme var), same in light/dark. */
  background: rgba(30, 88, 1, 0.3);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 8px 18px -12px rgba(16, 24, 40, .35);
}
.vote-query-card .q-id { font-size: 12px; color: var(--primary); font-weight: 700; letter-spacing: .04em; }
.vote-query-card .q-text { font-size: 18px; margin: 4px 0 0; }

.cand-card {
  display: grid;
  grid-template-columns: 3fr 1fr;
  gap: 0 18px;
  align-items: stretch;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0;
  transition: border-color .15s, box-shadow .15s;
}
.cand-main { min-width: 0; }
.cand-head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.cand-head .cid { font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .04em; }
.cand-title { font-size: 13.5px; margin: 6px 0 10px; line-height: 1.4; }
.cand-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 4px 16px;
  font-size: 12px;
}
.cand-facts .k { color: var(--muted); margin-right: 6px; }

.cand-vote {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  background: var(--panel-2);
  border-radius: 10px;
  padding: 12px 14px;
}
.cand-vote-label { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.cand-missing-msg { font-size: 12px; font-weight: 700; color: var(--danger); }

.cand-card.missing {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.28);
}
.hint.err { color: var(--danger); font-size: 12.5px; font-weight: 600; margin-top: 10px; }

.score-opts { display: flex; gap: 6px; }
.score-opt { position: relative; flex: 1; }
.score-opt input {
  position: absolute;
  opacity: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  cursor: pointer;
}
.score-opt input:disabled { cursor: not-allowed; }
.score-btn {
  display: block;
  text-align: center;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-weight: 700;
}
.score-opt input:checked + .score-btn[data-score="0"] { background: var(--danger); border-color: var(--danger); color: #fff; }
.score-opt input:checked + .score-btn[data-score="1"] { background: var(--primary); border-color: var(--primary); color: #fff; }
.score-opt input:checked + .score-btn[data-score="2"] { background: var(--ok); border-color: var(--ok); color: #fff; }
.score-opt input:disabled + .score-btn { opacity: .5; }

.cand-vote .ei {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.cand-vote .ei input[type=checkbox] { width: 16px; height: 16px; margin: 0; flex-shrink: 0; }

.cand-vote select, .cand-vote textarea {
  width: 100%;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 9px;
  font-family: inherit;
  font-size: 12px;
  margin: 0;
  min-height: unset;
}
.cand-vote label { font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; margin-bottom: 4px; }

.vote-actions { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.vote-muted { color: var(--muted); font-size: 12.5px; line-height: 1.6; margin-top: 8px; }

@media (max-width: 760px) {
  .cand-card { grid-template-columns: 1fr; }
  .cand-vote { border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; }
}

/* ------- Reason/score guide sidebar (mirrors dashboard #vote-reason-guide) ------- */

.wrap.wrap-wide { max-width: 1300px; }

.vote-shell {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}
.vote-main { flex: 1; min-width: 0; }

#vote-reason-guide {
  width: 340px;
  flex-shrink: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 16px 20px;
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
}
#vote-reason-guide h3 {
  font-size: 14px;
  color: var(--text);
  margin: 0 0 8px;
}
#vote-reason-guide h3:not(:first-of-type) {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.guide-lead {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.55;
  margin: 0 0 12px;
}
.reason-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 14px; }
.reason-chips span {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--border);
  color: var(--text);
}
.reason-guide-table { width: 100%; border-collapse: collapse; }
.reason-guide-table th, .reason-guide-table td {
  text-align: left;
  padding: 7px 6px;
  border-bottom: 1px solid var(--border);
  font-size: 11.5px;
  vertical-align: top;
  line-height: 1.4;
}
.reason-guide-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 10px;
  text-transform: uppercase;
}
.reason-guide-table td.code { font-weight: 700; white-space: nowrap; width: 60px; }

@media (max-width: 1100px) {
  .vote-shell { flex-direction: column; }
  #vote-reason-guide {
    width: 100%;
    max-height: none;
    position: static;
  }
}
