/* Proposal Evaluation Platform — single stylesheet for every page.
   Visual language follows the AI Council viewer the proposals come from:
   light blue-tinted background, white cards, soft shadows, 18px radius. */

:root {
  --bg: #eef3fb;
  --surface-0: #ffffff;
  --surface-1: #f3f6fc;
  --surface-2: #eaeef7;
  --border: #e4e9f2;
  --border-strong: #cdd8ea;
  --text: #16202f;
  --text-2: #47566b;
  --muted: #8a95a7;
  --accent: #2f6bff;
  --accent-ink: #245ce0;
  --purple: #7c5cff;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --shadow: 0 10px 34px rgba(15, 23, 42, .06);
  --shadow-sm: 0 2px 10px rgba(24, 45, 90, .05);
  --radius: 20px;
  --radius-sm: 12px;
}


* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  background: linear-gradient(180deg, #f7f9fc 0%, #eef3fb 45%, #d3e2ff 100%) fixed;
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px; line-height: 1.55; -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { letter-spacing: -.3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

/* ---------- topbar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 22px; background: rgba(255, 255, 255, .82); backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(15, 23, 42, .06); position: sticky; top: 0; z-index: 30;
}
.topbar .brand { font-weight: 800; font-size: 16px; white-space: nowrap; color: var(--text); }
.topbar .brand span { color: var(--accent); }
.topbar nav { display: flex; gap: 4px; margin-left: 10px; flex-wrap: wrap; }
.topbar nav a { padding: 6px 12px; border-radius: 999px; color: var(--text-2); font-size: 13.5px; font-weight: 600; }
.topbar nav a:hover { background: var(--surface-1); text-decoration: none; }
.topbar nav a[aria-current="page"] { background: var(--surface-2); color: var(--text); }
.topbar .spacer { flex: 1; }
.topbar .who { font-size: 12.5px; color: var(--muted); white-space: nowrap; }

/* ---------- layout ---------- */
.workspace {
  display: grid; grid-template-columns: 310px minmax(0, 1fr) 260px;
  gap: 18px; align-items: start; padding: 18px 22px 70px; max-width: 1680px; margin: 0 auto;
}
.page { max-width: 1200px; margin: 0 auto; padding: 22px; }
.rail { position: sticky; top: 74px; max-height: calc(100vh - 92px); overflow-y: auto; }
@media (max-width: 1240px) {
  .workspace { grid-template-columns: 290px minmax(0, 1fr); }
  .rail-right { display: none; }
}
@media (max-width: 880px) {
  .workspace { grid-template-columns: 1fr; padding: 12px; }
  .rail { position: static; max-height: none; }
  .rail-left { display: none; }
  .rail-left.open { display: block; }
  .drawer-toggle { display: inline-flex !important; }
}
.drawer-toggle { display: none; }

/* ---------- cards ---------- */
.card {
  background: var(--surface-0); border: 1px solid transparent;
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px;
}
.card + .card { margin-top: 14px; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.card-head h2 { flex: 1; margin: 0; }

/* ---------- proposal browser ---------- */
.search {
  width: 100%; padding: 9px 12px; font-size: 14px; color: var(--text);
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); margin-bottom: 10px;
}
.proposal-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.proposal-item {
  width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit;
  background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 11px 12px; display: grid; gap: 6px;
}
.proposal-item:hover { border-color: var(--border-strong); }
.proposal-item.active { background: var(--surface-0); border-color: var(--accent); box-shadow: var(--shadow-sm); }
.proposal-item .t { font-weight: 700; font-size: 13.5px; line-height: 1.35; }
.proposal-item .s { font-size: 12px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.proposal-item .meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); }

.progress-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; flex: 1; }
.progress-bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .25s; }

/* ---------- sections + blocks ---------- */
.section-card { background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); margin-bottom: 16px; overflow: hidden; }
.section-head { padding: 13px 18px; border-bottom: 1px solid var(--border); background: var(--surface-1); display: flex; align-items: center; gap: 10px; }
.section-head h2 { margin: 0; font-size: 15px; flex: 1; }
.block { padding: 16px 18px; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.block:last-child { border-bottom: 0; }
.block:target, .block.flash { background: var(--surface-1); }
.block-heading { font-weight: 700; font-size: 14px; color: var(--text); }
.block-body { color: var(--text-2); font-size: 14.5px; overflow-wrap: anywhere; }
.block-body p { margin: 0 0 8px; }
.block-body ul, .block-body ol { margin: 0 0 8px; padding-left: 20px; }
.block-body table { width: 100%; border-collapse: collapse; font-size: 13px; }
.block-body th, .block-body td { border-bottom: 1px solid var(--border); padding: 6px 8px; text-align: left; vertical-align: top; }
.block-key { font-size: 11px; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- rating widget ---------- */
.rating { display: grid; gap: 8px; padding-top: 4px; border-top: 1px dashed var(--border); }
.rating-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rating-label { font-size: 12px; color: var(--muted); font-weight: 600; }
.score-btns { display: inline-flex; gap: 4px; }
.score-btn {
  width: 34px; height: 34px; border-radius: 9px; cursor: pointer;
  background: var(--surface-1); color: var(--text-2);
  border: 1px solid var(--border); font-weight: 700; font-size: 13.5px;
  font-family: inherit; transition: transform .05s, background .15s, color .15s, border-color .15s;
}
.score-btn:hover { border-color: var(--border-strong); }
.score-btn:active { transform: translateY(1px); }
.score-btn.selected { color: #fff; border-color: transparent; }
.score-btn.selected[data-score="1"] { background: #dc2626; }
.score-btn.selected[data-score="2"] { background: #ea580c; }
.score-btn.selected[data-score="3"] { background: #d97706; }
.score-btn.selected[data-score="4"] { background: #65a30d; }
.score-btn.selected[data-score="5"] { background: #16a34a; }

.comment-wrap { display: grid; gap: 4px; }
.comment-prompt { font-size: 12px; color: var(--muted); }
.comment-box {
  width: 100%; min-height: 62px; resize: vertical; font: inherit; font-size: 13.5px;
  color: var(--text); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px;
}
.comment-box:disabled {
  opacity: .5; cursor: not-allowed; background: var(--surface-2);
  border-style: dashed; min-height: 40px;
}
.save-state { font-size: 11.5px; color: var(--muted); min-width: 58px; }
.save-state.saving { color: var(--warn); }
.save-state.saved { color: var(--ok); }
.save-state.error { color: var(--bad); font-weight: 600; }

/* ---------- stats / tables / feedback ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat-card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.stat-card .v { font-size: 22px; font-weight: 800; letter-spacing: -.5px; }
.stat-card .k { font-size: 12px; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.table th { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.table th[data-sort] { cursor: pointer; user-select: none; }
.table th[data-sort]:hover { color: var(--text); }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: var(--surface-1); }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; }

.bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-2); min-width: 70px; }
.bar > .h { background: var(--ok); }
.bar > .n { background: var(--bad); }

.histogram { display: flex; align-items: flex-end; gap: 3px; height: 36px; }
.histogram .hbar { width: 14px; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; }
.histogram .hlab { font-size: 10px; color: var(--muted); text-align: center; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 11.5px; font-weight: 700; background: var(--surface-2); color: var(--text-2); }
.badge.helpful { background: rgba(22,163,74,.13); color: var(--ok); }
.badge.not-helpful { background: rgba(220,38,38,.13); color: var(--bad); }

.comment-card { background: var(--surface-1); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); padding: 9px 12px; margin-top: 8px; }
.comment-card .meta { font-size: 11.5px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 3px; }
.comment-card .body { font-size: 13.5px; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- auth ---------- */
.auth-card { max-width: 420px; margin: 9vh auto; background: var(--surface-0); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 28px; }
.auth-card h1 { margin: 0 0 6px; font-size: 21px; }
.auth-card .sub { color: var(--muted); font-size: 13.5px; margin-bottom: 18px; }
.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field input { padding: 10px 12px; font-size: 15px; font-family: inherit; color: var(--text); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.otp-inputs { display: flex; gap: 8px; justify-content: space-between; }
.otp-input { width: 100%; aspect-ratio: 1/1.15; text-align: center; font-size: 22px; font-weight: 700; font-family: inherit; color: var(--text); background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.otp-input:focus { border-color: var(--accent); }

/* ---------- buttons + utilities ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  background: var(--surface-0); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 14px; font-size: 13.5px; font-weight: 600;
  font-family: inherit; cursor: pointer; box-shadow: var(--shadow-sm);
}
.btn:hover { border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; }
.btn.primary:hover { background: var(--accent-ink); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.danger { color: var(--bad); }
.btn.full { width: 100%; }

.chip { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.error-text { color: var(--bad); font-size: 13px; margin: 6px 0 0; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state h3 { margin: 0 0 6px; color: var(--text); font-size: 16px; }

.spinner { width: 16px; height: 16px; border: 2px solid var(--border-strong); border-top-color: var(--accent); border-radius: 50%; display: inline-block; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast-host { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 100; }
.toast { background: var(--surface-0); border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 14px; font-size: 13.5px; max-width: 340px; }
.toast.error { border-left-color: var(--bad); }
.toast.success { border-left-color: var(--ok); }

.dropzone { border: 2px dashed var(--border-strong); border-radius: var(--radius-sm); padding: 14px; text-align: center; color: var(--muted); font-size: 12.5px; cursor: pointer; }
.dropzone.over { border-color: var(--accent); color: var(--accent); background: var(--surface-1); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- embedded proposal document ---------- */
.doc-shell {
  background: var(--surface-0); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden;
}
.doc-shell iframe {
  display: block; width: 100%; min-height: 70vh; border: 0; background: #fff;
}

/* ---------- reason tags ---------- */
.tag-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.tag-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: rgba(47, 107, 255, .1); color: var(--accent);
  border-radius: 99px; padding: 2px 9px; font-size: 11.5px; font-weight: 600;
}
.tag-chip b { background: rgba(47, 107, 255, .18); border-radius: 99px; padding: 0 5px; font-size: 10.5px; }
.tag-chip.muted-chip { background: var(--surface-2); color: var(--text-2); font-weight: 500; }
.tag-chip.muted-chip b { background: rgba(0, 0, 0, .08); }
