/* AI Team 2026 review. White pages with red as the brand colour.
   Charts keep their meaning colours: Likert is diverging red (disagree) <-> blue (agree)
   with a gray midpoint, so single-series bars are charcoal rather than brand red. */
:root {
  color-scheme: light;
  --plane: #ffffff;
  --surface: #ffffff;
  --tint: #f6f6f6;
  --ink: #191919;
  --ink-2: #5f5f5f;
  --grid: #e7e7e7;
  --axis: #c2c2c2;
  --accent: #c8102e;
  --accent-dark: #9e0c24;
  --accent-ink: #ffffff;
  --accent-soft: #fdecef;
  --good: #006c10;
  --good-bg: #e7f4e9;
  --warn-bg: #fff4dc;
  --warn-ink: #6b4a00;
  --err: #b3261e;
  --err-bg: #fdecea;
  --l1: #b8292b;
  --l2: #ee7d7d;
  --l3: #d0d0d0;
  --l4: #6aabf1;
  --l5: #1b64be;
  --on-l1: #ffffff; --on-l2: #191919; --on-l3: #191919; --on-l4: #191919; --on-l5: #ffffff;
  --bar: #3d3d3d;
  --radius: 12px;
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--plane);
  line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; border-top: 6px solid var(--accent); }
body:has(.topbar) { border-top: 0; }
main { margin: 0 auto; padding: 24px 16px 64px; }
main.narrow { max-width: 760px; }
main.wide { max-width: 1180px; }
h1 { font-size: 1.75rem; line-height: 1.2; margin: 0.2em 0 0.4em; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; margin: 0 0 0.6em; }
h3 { font-size: 1rem; margin: 0 0 0.4em; }
a { color: var(--accent); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; background: var(--tint); padding: 1px 6px; border-radius: 6px; }
.muted { color: var(--ink-2); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.lead { font-size: 1.05rem; }

.card { background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius); padding: 20px 22px; margin: 0 0 16px; }
.cardhead { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px 16px; margin-bottom: 8px; }
.cardhead h2 { margin: 0; }
.cardhead p { margin: 0; }
.pagehead { margin: 8px 0 16px; }
.pagehead p { margin: 0; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; font-weight: 700; color: var(--accent); margin: 0; }
.intro h2 { margin-top: 1.2em; }
.facts { padding-left: 1.1em; }
.facts li { margin: 0.35em 0; }

.button { display: inline-block; font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 18px; cursor: pointer; text-decoration: none; }
.button:hover { background: var(--accent-dark); }
.button:disabled { opacity: 0.5; cursor: progress; }
.button.big { font-size: 1.05rem; padding: 14px 26px; }
.button.danger { background: var(--surface); color: var(--err); border: 2px solid var(--err); }
.button.danger:hover { background: var(--err-bg); }
button.link { font: inherit; background: none; border: 0; color: var(--ink-2); cursor: pointer; padding: 0; }
button.link:hover { color: var(--ink); text-decoration: underline; }
input[type=text], input[type=password], textarea { font: inherit; color: var(--ink); background: var(--plane); border: 1px solid var(--axis); border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus-visible, textarea:focus-visible, .button:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
textarea { resize: vertical; min-height: 6em; }
.codeform label { display: block; font-weight: 600; margin: 12px 0 6px; }
.codeform .row { display: flex; gap: 10px; }
.codeform .row input { flex: 1; }

.flash, .notice { background: var(--tint); border-left: 4px solid var(--accent); border-radius: 6px; padding: 10px 14px; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: 10px; padding: 10px 14px; }
.error { color: var(--err); font-weight: 600; margin: 0.3em 0; }
.pill { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 1px 8px; border-radius: 999px; background: var(--grid); color: var(--ink); vertical-align: middle; }
.pill.ok { background: var(--good-bg); color: var(--good); }

/* ---------- questionnaire ---------- */
.progressbar { position: sticky; top: 0; z-index: 5; background: var(--plane); padding: 10px 0 8px; display: flex; align-items: center; gap: 12px; }
.progressbar progress { flex: 1; height: 8px; appearance: none; border: 0; border-radius: 99px; background: var(--grid); overflow: hidden; }
.progressbar progress::-webkit-progress-bar { background: var(--grid); border-radius: 99px; }
.progressbar progress::-webkit-progress-value { background: var(--accent); border-radius: 99px; }
.progressbar progress::-moz-progress-bar { background: var(--accent); border-radius: 99px; }
.qsection h2 { display: flex; align-items: center; gap: 10px; }
.secno { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); font-size: 0.9rem; }
fieldset.q { min-width: 0; border: 0; margin: 0; padding: 14px 0; border-top: 1px solid var(--grid); }
fieldset.q:first-of-type { border-top: 0; }
fieldset.q legend { font-weight: 600; padding: 0; margin-bottom: 10px; float: left; width: 100%; }
fieldset.q legend + * { clear: both; }
fieldset.has-error { background: var(--err-bg); border-radius: 10px; padding: 14px 12px; }
.opts { display: grid; gap: 8px; clear: both; }
.opts.likert { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.opts.scale { grid-template-columns: repeat(11, minmax(0, 1fr)); gap: 6px; }
.opts.choice { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); }
.opt { position: relative; display: block; cursor: pointer; }
.opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: 44px; padding: 6px 8px; border: 1px solid var(--axis); border-radius: 10px; background: var(--surface); font-size: 0.9rem; line-height: 1.2; transition: background 0.1s, border-color 0.1s; }
.opts.choice .opt span { justify-content: flex-start; text-align: left; }
.opt:hover span { border-color: var(--accent); }
.opt input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.opt input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.opt input:disabled + span { opacity: 0.45; cursor: not-allowed; }
.scale-ends { display: flex; justify-content: space-between; margin-top: 4px; }
.submitbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-top: 8px; }
@media (max-width: 640px) {
  .opts.likert { grid-template-columns: 1fr; }
  .opts.likert { gap: 6px; }
  .opts.likert .opt span { justify-content: flex-start; min-height: 40px; }
  main { padding: 16px 12px 48px; }
  .card { padding: 16px 14px; }
  .opts.scale { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

/* ---------- dashboard ---------- */
.topbar { background: var(--accent); color: var(--accent-ink); }
.topbar-inner { max-width: 1180px; margin: 0 auto; padding: 10px 16px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; }
.brand { font-weight: 700; color: var(--accent-ink); text-decoration: none; }
.topbar nav { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
.topbar nav a { color: var(--accent-ink); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.topbar nav a:hover { background: var(--accent-dark); }
.topbar nav a[aria-current=page] { color: var(--accent); background: var(--surface); font-weight: 600; }
.topbar button.link { color: var(--accent-ink); }
.topbar button.link:hover { color: var(--accent-ink); }
.topbar a:focus-visible, .topbar button:focus-visible { outline: 3px solid var(--accent-ink); outline-offset: 2px; }
.logout { margin: 0; }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--surface); border: 1px solid var(--grid); border-radius: var(--radius); padding: 16px 18px; }
.tile-label { color: var(--ink-2); font-size: 0.85rem; }
.tile-value { font-size: 2.2rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.tile-of { font-size: 1rem; font-weight: 500; color: var(--ink-2); }
.tile-note { color: var(--ink-2); font-size: 0.8rem; }

.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.grid2 > .card, .grid3 > .card { margin: 0 0 16px; }

table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--grid); vertical-align: middle; }
thead th { font-size: 0.8rem; font-weight: 600; color: var(--ink-2); }
tbody th { font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.barcol { width: 45%; min-width: 220px; }

.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; list-style: none; padding: 0; margin: 0; font-size: 0.8rem; color: var(--ink-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.swatch.l1, .l1 { fill: var(--l1); background: var(--l1); }
.swatch.l2, .l2 { fill: var(--l2); background: var(--l2); }
.swatch.l3, .l3 { fill: var(--l3); background: var(--l3); }
.swatch.l4, .l4 { fill: var(--l4); background: var(--l4); }
.swatch.l5, .l5 { fill: var(--l5); background: var(--l5); }

svg { display: block; overflow: visible; }
svg rect.track { fill: var(--tint); }
svg rect.seg { stroke: var(--surface); stroke-width: 2px; }
svg text { font-size: 11px; font-variant-numeric: tabular-nums; }
svg text.seglabel { font-weight: 600; pointer-events: none; }
svg text.seglabel.l1 { fill: var(--on-l1); }
svg text.seglabel.l2 { fill: var(--on-l2); }
svg text.seglabel.l3 { fill: var(--on-l3); }
svg text.seglabel.l4 { fill: var(--on-l4); }
svg text.seglabel.l5 { fill: var(--on-l5); }
svg rect:hover { filter: brightness(1.1); }
.lbar { margin: 6px 0 2px; }

.items { list-style: none; padding: 0; margin: 0; }
.items li { padding: 10px 0; border-top: 1px solid var(--grid); }
.items li:first-child { border-top: 0; padding-top: 0; }
.item-text { font-weight: 600; }

.cbars { list-style: none; padding: 0; margin: 8px 0 0; }
.cbars li { display: grid; grid-template-columns: minmax(120px, 42%) 1fr 2.5em; align-items: center; gap: 10px; padding: 3px 0; font-size: 0.9rem; }
.cbar rect { fill: var(--bar); }
.ccount { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.hist .base { stroke: var(--axis); stroke-width: 1px; }
.hist rect.hb { fill: var(--bar); }
.hist rect.hb.l2 { fill: var(--l2); }
.hist rect.hb.l3 { fill: var(--l3); }
.hist rect.hb.l5 { fill: var(--l5); }
.hist .hcount { fill: var(--ink); font-weight: 600; }
.hist .hlabel { fill: var(--ink-2); }

.qstat { padding: 14px 0; border-top: 1px solid var(--grid); }
.qstat:first-of-type { border-top: 0; }
.qstat-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; font-weight: 600; }
.qstat-head .muted { font-weight: 400; }
.counts { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 4px 0 0; }

.toc ol { margin: 0; padding-left: 1.2em; }
.answers { list-style: none; padding: 0; margin: 0; }
.answers li { white-space: pre-wrap; overflow-wrap: anywhere; padding: 10px 14px; margin: 8px 0; background: var(--tint); border-left: 3px solid var(--axis); border-radius: 6px; }

.themes { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 12px; }
.theme { border: 1px solid var(--grid); border-left-width: 4px; border-radius: 10px; padding: 12px 14px; }
.theme.sent-positive { border-left-color: var(--l5); }
.theme.sent-mixed { border-left-color: var(--l3); }
.theme.sent-negative { border-left-color: var(--l1); }
.pill.sent-positive { background: var(--l5); color: var(--on-l5); }
.pill.sent-mixed { background: var(--l3); color: var(--on-l3); }
.pill.sent-negative { background: var(--l1); color: var(--on-l1); }
.pill.prio-high { background: var(--l1); color: var(--on-l1); }
.pill.prio-medium { background: var(--l3); color: var(--on-l3); }
.pill.prio-low { background: var(--grid); }
.evidence { margin: 6px 0 0; padding-left: 1.1em; color: var(--ink-2); font-size: 0.9rem; }
.actions td { vertical-align: top; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 8px 16px; margin: 0 0 8px; }
.kv dt { color: var(--ink-2); }
.kv dd { margin: 0; }
.card.danger { border-color: var(--err); }
.locked { text-align: left; }
