/* CAQ Barometer 2026 · Exemplar Selection dashboard */
:root {
  --navy: #0B1F33;
  --navy-2: #163A5C;
  --navy-soft: #E8EEF5;
  --gold: #F5C400;
  --gold-soft: #FFF7CC;
  --gold-ink: #6B5600;
  --ink: #1B2733;
  --muted: #55657A;
  --line: #D9E0E8;
  --line-strong: #B9C4D1;
  --surface: #F4F6F9;
  --white: #FFFFFF;
  --danger: #A62B2B;
  --danger-soft: #FBE9E9;
  --ok: #1E6B3A;
  --ok-soft: #E4F3EA;
  --warn-soft: #FFF3D6;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(11,31,51,.06), 0 6px 20px rgba(11,31,51,.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tap: 44px;
  --pager-h: 64px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 120px; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--white);
  -webkit-font-smoothing: antialiased;
  overflow-wrap: anywhere;
}
h1, h2, h3, h4 { color: var(--navy); margin: 0; line-height: 1.25; letter-spacing: -0.01em; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .92em; background: var(--surface); padding: .05em .35em; border-radius: 4px; }
button { font: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--gold); color: var(--navy); padding: .5rem .9rem; border-radius: 8px; z-index: 100; font-weight: 700; }
.skip-link:focus { left: 8px; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--navy);
  color: #fff;
  border-bottom: 4px solid var(--gold);
  position: sticky; top: 0; z-index: 20;
  padding-top: env(safe-area-inset-top);
}
.topbar__inner {
  max-width: 1280px; margin: 0 auto;
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand__mark { width: 12px; height: 40px; background: var(--gold); border-radius: 3px; flex: none; }
.brand__text { min-width: 0; }
.brand__kicker--short { display: none; }
.brand__kicker { display: block; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: #C9D6E4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand__title { color: #fff; font-size: 20px; font-weight: 700; }
.topbar__actions { display: flex; align-items: center; gap: 12px; flex: none; }
.progress { display: flex; flex-direction: column; gap: 4px; min-width: 140px; }
.progress__label { font-size: 13px; color: #E3EAF2; white-space: nowrap; }
.progress__bar { display: block; height: 6px; background: rgba(255,255,255,.18); border-radius: 3px; overflow: hidden; }
.progress__fill { display: block; height: 100%; width: 0; background: var(--gold); border-radius: 3px; transition: width .3s ease; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 18px;
  border-radius: 10px; border: 2px solid transparent;
  font-weight: 600; font-size: 15px; cursor: pointer; text-decoration: none;
  transition: background .15s, color .15s, border-color .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn--gold { background: var(--gold); color: var(--navy); }
.btn--gold:hover { background: #FFD21F; }
.btn--navy { background: var(--navy); color: #fff; }
.btn--navy:hover { background: var(--navy-2); }
.btn--outline { background: #fff; color: var(--navy); border-color: var(--line-strong); }
.btn--outline:hover { border-color: var(--navy); background: var(--navy-soft); }
.btn--ghost { background: transparent; color: inherit; }
.btn--danger { background: var(--danger); color: #fff; }
.btn--sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.file-pick { position: relative; overflow: hidden; }
.file-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; }
.file-pick:focus-within { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ---------- Layout ---------- */
.layout { max-width: 1280px; margin: 0 auto; display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; padding: 24px 16px calc(var(--pager-h) + 24px); }
.main { min-width: 0; }

/* Question nav (sidebar on desktop, chip rail on mobile) */
.qnav { position: sticky; top: 92px; align-self: start; max-height: calc(100vh - 110px); overflow: auto; min-width: 0; }
.qnav__heading { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; margin: 0 0 8px 4px; }
.qnav__list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.qbtn {
  width: 100%; display: grid; grid-template-columns: auto minmax(0,1fr) auto; align-items: center; gap: 10px;
  min-height: var(--tap); padding: 8px 10px; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm); color: var(--ink); cursor: pointer;
}
.qbtn:hover { border-color: var(--line-strong); background: var(--surface); }
.qbtn[aria-current="true"] { border-color: var(--navy); background: var(--navy-soft); box-shadow: inset 4px 0 0 var(--gold); }
.qbtn__id { font-weight: 800; color: var(--navy); font-variant-numeric: tabular-nums; min-width: 34px; }
.qbtn__title { font-size: 13.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qbtn__state { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; font-size: 12px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.qbtn__state .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); display: inline-block; }
.qbtn__state.is-locked .dot { background: var(--ok); }
.qbtn__state.is-partial .dot { background: var(--gold); }

/* ---------- Question header ---------- */
.qhead { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px 24px; }
.qhead__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.qhead__idrow { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 8px; }
.qid { display: inline-block; background: var(--navy); color: var(--gold); font-weight: 800; padding: 3px 10px; border-radius: 6px; font-size: 14px; letter-spacing: .02em; }
.qhead__title { font-size: 24px; }
.qhead__construct { margin-top: 10px; font-size: 16.5px; color: var(--ink); max-width: 72ch; }
.criteria { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 18px; }
.criterion { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; background: var(--surface); position: relative; }
.criterion__label { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--navy); margin-bottom: 6px; }
.criterion__text { font-size: 15px; color: var(--ink); }
.criterion--r3 { background: var(--gold-soft); border-color: #EBD77A; }

.rbadge { display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 24px; padding: 0 8px; border-radius: 6px; font-weight: 800; font-size: 12.5px; letter-spacing: .03em; }
.rbadge--2 { background: #fff; color: var(--navy); border: 2px solid var(--navy); }
.rbadge--3 { background: var(--navy); color: var(--gold); border: 2px solid var(--navy); }

/* Lock / status controls */
.statusbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 12px; border-radius: 15px; font-weight: 700; font-size: 13px; }
.pill--locked { background: var(--ok-soft); color: var(--ok); }
.pill--open { background: var(--surface); color: var(--muted); border: 1px solid var(--line); }
.statusbar__hint { font-size: 13.5px; color: var(--muted); flex: 1 1 200px; }
.locknote { margin-top: 12px; padding: 10px 14px; background: var(--navy-soft); border-left: 4px solid var(--navy); border-radius: 6px; font-size: 14px; color: var(--ink); }
.locknote strong { color: var(--navy); }

/* ---------- Rating sections ---------- */
.rsection { margin-top: 28px; }
.rsection__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.rsection__title { display: flex; align-items: center; gap: 10px; font-size: 18px; }
.rsection__count { font-size: 14px; font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.rsection__count.is-full { color: var(--ok); }
.rsection__count.is-over { color: var(--danger); }
.rsection__warn { flex-basis: 100%; background: var(--warn-soft); border: 1px solid #EBD77A; color: var(--gold-ink); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 14px; }
.cards { display: grid; gap: 14px; }

/* ---------- Candidate card ---------- */
.card {
  position: relative; scroll-margin-top: 120px; min-width: 0;
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 18px 20px 18px 20px;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.card.is-selected { border-color: var(--gold); background: #FFFDF2; box-shadow: 0 0 0 3px var(--gold-soft), var(--shadow); }
.card.is-selected::before { content: ""; position: absolute; left: -1.5px; top: 14px; bottom: 14px; width: 5px; background: var(--gold); border-radius: 0 4px 4px 0; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.card__company { font-size: 18px; font-weight: 700; color: var(--navy); }
.card__meta { display: flex; flex-wrap: wrap; gap: 6px 8px; margin-top: 6px; font-size: 13px; color: var(--muted); align-items: center; }
.chip { display: inline-flex; align-items: center; height: 24px; padding: 0 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; font-weight: 600; color: var(--ink); white-space: nowrap; }
.chip--mono { font-family: var(--mono); font-weight: 500; font-size: 12.5px; letter-spacing: 0; }
.chip--lock { background: var(--ok-soft); border-color: #BBDDC6; color: var(--ok); }
.chip--pre { background: var(--gold-soft); border-color: #EBD77A; color: var(--gold-ink); }

/* Selection toggle: real checkbox + big label */
.sel { flex: none; }
.sel input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.sel__box {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: var(--tap); padding: 0 14px 0 10px;
  border: 2px solid var(--line-strong); border-radius: 10px; background: #fff;
  color: var(--navy); font-weight: 700; font-size: 14px; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s;
}
.sel__box::before { content: ""; width: 20px; height: 20px; border-radius: 6px; border: 2px solid var(--navy); background: #fff; flex: none; display: inline-block; }
.sel input:checked + .sel__box { background: var(--navy); border-color: var(--navy); color: var(--gold); }
.sel input:checked + .sel__box::before { background: var(--gold); border-color: var(--gold); background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='none' stroke='%230B1F33' stroke-width='3' stroke-linecap='round' stroke-linejoin='round' d='M4 10.5l4 4 8-9'/%3E%3C/svg%3E"); background-size: 16px; background-position: center; background-repeat: no-repeat; }
.sel input:focus-visible + .sel__box { outline: 3px solid var(--gold); outline-offset: 2px; }
.sel__on, .sel__off { display: none; }
.sel input:checked + .sel__box .sel__on { display: inline; }
.sel input:not(:checked) + .sel__box .sel__off { display: inline; }

.card__body { margin-top: 14px; display: grid; gap: 12px; }
.field__label { display: block; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.evidence { margin: 0; background: var(--surface); border-left: 4px solid var(--navy); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; padding: 12px 14px; font-size: 15.5px; line-height: 1.55; color: var(--ink); }
.field__text { font-size: 15px; }
.field__text--loc { font-size: 14.5px; font-weight: 500; color: var(--navy); }
.reason { font-size: 15px; }
.reason + .reason { margin-top: 6px; }
.reason__tag { font-weight: 700; color: var(--navy); }
.caveat { background: var(--warn-soft); border: 1px solid #EBD77A; border-radius: var(--radius-sm); padding: 10px 12px; font-size: 14px; color: var(--gold-ink); }
.caveat strong { color: var(--gold-ink); }

/* Prior-lock entry that has no shortlist card */
.card--ghost { border-style: dashed; background: var(--surface); box-shadow: none; }
.card--ghost.is-selected { background: #FFFDF2; border-style: solid; }
.card--ghost .card__note { font-size: 14px; color: var(--muted); margin-top: 8px; }

/* Notes */
.notes { margin-top: 28px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.notes label { display: block; font-weight: 700; color: var(--navy); margin-bottom: 6px; }
.notes textarea { width: 100%; min-height: 96px; resize: vertical; font: inherit; font-size: 15px; padding: 10px 12px; border: 1.5px solid var(--line-strong); border-radius: var(--radius-sm); color: var(--ink); }
.notes textarea:focus { border-color: var(--navy); outline: 3px solid var(--gold-soft); }
.notes__hint { font-size: 13px; color: var(--muted); margin-top: 6px; }

.empty { padding: 20px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); color: var(--muted); text-align: center; font-size: 14.5px; }

/* ---------- Pager (bottom, mobile-first) ---------- */
.pager {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 15;
  max-width: 1280px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96); backdrop-filter: saturate(160%) blur(8px); -webkit-backdrop-filter: saturate(160%) blur(8px);
  border-top: 1px solid var(--line);
}
.pager__pos { font-weight: 700; color: var(--navy); font-variant-numeric: tabular-nums; text-align: center; font-size: 14px; }
.pager .btn { min-width: 104px; }

/* ---------- Notices / toast ---------- */
.notice { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; color: var(--muted); }
.notice--error { background: var(--danger-soft); border-color: #E7B9B9; color: var(--ink); display: grid; gap: 10px; justify-items: start; }
.toast { position: fixed; left: 50%; bottom: calc(var(--pager-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; box-shadow: var(--shadow); z-index: 40; max-width: calc(100vw - 32px); text-align: center; }

/* ---------- Dialog ---------- */
.dialog { border: none; border-radius: var(--radius); padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(11,31,51,.3); color: var(--ink); }
.dialog::backdrop { background: rgba(11,31,51,.55); }
.dialog__inner { padding: 22px 24px; display: grid; gap: 14px; margin: 0; }
.dialog__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog__head h2 { font-size: 20px; }
.dialog__close { min-height: 40px; min-width: 40px; padding: 0; font-size: 18px; color: var(--muted); }
.dialog__lede { font-size: 15px; color: var(--muted); }
.dialog__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.dialog__status { min-height: 1.2em; font-size: 14px; color: var(--ok); font-weight: 600; }
.dialog__preview summary, .dialog__danger summary { cursor: pointer; font-weight: 700; color: var(--navy); min-height: var(--tap); display: flex; align-items: center; gap: 8px; list-style: none; }
.dialog__preview summary::-webkit-details-marker, .dialog__danger summary::-webkit-details-marker { display: none; }
.dialog__preview summary::before, .dialog__danger summary::before { content: '▸'; color: var(--gold-ink); font-size: 14px; transition: transform .15s; }
.dialog__preview[open] summary::before, .dialog__danger[open] summary::before { transform: rotate(90deg); }
.dialog__preview pre { margin: 0; max-height: 40vh; overflow: auto; background: var(--navy); color: #E7EEF6; padding: 14px; border-radius: var(--radius-sm); font-family: var(--mono); font-size: 12.5px; line-height: 1.45; }
.dialog__danger { border-top: 1px solid var(--line); padding-top: 6px; }
.dialog__danger p { font-size: 14px; color: var(--muted); margin-bottom: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; gap: 16px; padding-top: 14px; }
  .qnav { position: static; max-height: none; overflow: visible; }
  .qnav__heading { display: none; }
  .qnav__list { flex-direction: row; overflow-x: auto; max-width: 100%; gap: 8px; padding: 2px 2px 8px; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
  .qbtn { width: auto; grid-template-columns: auto auto; min-height: 42px; padding: 6px 12px; flex: none; scroll-snap-align: start; border-radius: 21px; }
  .qbtn__title { display: none; }
  .qbtn[aria-current="true"] { box-shadow: none; background: var(--navy); color: #fff; }
  .qbtn[aria-current="true"] .qbtn__id { color: var(--gold); }
  .qbtn[aria-current="true"] .qbtn__state { color: #E3EAF2; }
  .criteria { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  body { font-size: 15.5px; }
  .topbar__inner { padding: 8px 14px 10px; flex-wrap: wrap; row-gap: 6px; }
  .brand__mark { height: 34px; width: 10px; }
  .brand__kicker--long { display: none; }
  .brand__kicker--short { display: block; font-size: 11px; }
  .brand__title { font-size: 17px; }
  .topbar__actions { width: 100%; justify-content: space-between; }
  .progress { flex: 1; min-width: 0; }
  .topbar .btn { min-height: 40px; padding: 0 14px; }
  .layout { padding-left: 12px; padding-right: 12px; }
  .qhead { padding: 16px; border-radius: 12px; }
  .qhead__title { font-size: 20px; }
  .qhead__construct { font-size: 15.5px; }
  .criterion { padding: 12px 14px; }
  .card { padding: 14px 14px 16px; border-radius: 12px; }
  .card.is-selected::before { top: 12px; bottom: 12px; }
  .card__head { flex-direction: column; gap: 10px; }
  .card__company { font-size: 17px; }
  .sel { width: 100%; }
  .sel__box { width: 100%; justify-content: center; }
  .evidence { font-size: 15px; padding: 11px 12px; }
  .notes { padding: 14px; }
  .rsection__head { align-items: baseline; }
  .dialog__inner { padding: 18px 16px; }
  .dialog__actions .btn { flex: 1 1 100%; }
  .pager .btn { min-width: 0; flex: 1; }
  .pager__pos { flex: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media print {
  .topbar, .qnav, .pager, .toast, .sel { display: none !important; }
  .layout { display: block; padding: 0; }
  .card, .qhead { box-shadow: none; break-inside: avoid; }
}
