:root {
  --ink: #131a24;
  --ink-2: #3d4a5c;
  --muted: #6b7a8f;
  --line: #dfe4ec;
  --line-soft: #eef1f6;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --accent: #1d4ed8;
  --accent-soft: #eaf0ff;
  --hot: #b42318;
  --hot-bg: #fef3f2;
  --warm: #b54708;
  --warm-bg: #fffaeb;
  --cold: #475467;
  --cold-bg: #f2f4f7;
  --ok: #067647;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}

* { box-sizing: border-box; }

/* Must beat any display rule below, or a [hidden] overlay still covers the page
   and swallows every click. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 24px;
  height: 56px;
  background: var(--ink);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 30;
}
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: #fff; }
.brand-mark { font-weight: 700; letter-spacing: .12em; font-size: 15px; }
.brand-sub { color: #9aa8bd; font-size: 12px; letter-spacing: .01em; }
.topnav { display: flex; gap: 4px; margin-left: auto; }
.topnav a {
  color: #c3ccdb; text-decoration: none; padding: 6px 12px;
  border-radius: 6px; font-weight: 500;
}
.topnav a:hover { background: #23303f; color: #fff; }
.topnav a.is-active { background: #2b3a4d; color: #fff; }
.internal-tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: #8fa0b8; border: 1px solid #33465c; border-radius: 999px; padding: 3px 10px;
}
.whoami { font-size: 12px; color: #9aa8bd; white-space: nowrap; }
.whoami a { color: #c3ccdb; }
.whoami a:hover { color: #fff; }
.logout-form { display: inline; }
.logout-btn {
  background: none; border: 0; padding: 0; font: inherit; cursor: pointer;
  color: #c3ccdb;
}
.logout-btn:hover { color: #fff; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }
.wrap-narrow { max-width: 860px; margin: 0 auto; padding: 28px 24px 140px; }

h1 { font-size: 22px; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 4px; }
.page-head { margin-bottom: 20px; }
.page-head p { color: var(--muted); margin: 0; max-width: 68ch; }

/* --- Panels --- */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--line-soft); }
.panel-head .eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--accent); font-weight: 700;
}
.panel-head p { margin: 4px 0 0; color: var(--muted); }
.panel-body { padding: 18px 20px; }

/* --- Forms --- */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; }
.field.span-2 { grid-column: span 2; }
.field label { font-weight: 600; font-size: 13px; }
.field .req { color: var(--hot); }
input[type=text], input[type=email], input[type=tel], input[type=number], select, textarea {
  font: inherit; color: var(--ink);
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { min-height: 96px; resize: vertical; }
input:disabled { background: var(--line-soft); color: var(--ink-2); cursor: not-allowed; }
.field .err { color: var(--hot); font-size: 12px; min-height: 0; }
.field.has-error input, .field.has-error select { border-color: var(--hot); }

/* --- Questions --- */
.question { padding: 16px 20px; border-top: 1px solid var(--line-soft); }
.question:first-child { border-top: none; }
.question.is-answered .q-text { color: var(--ink-2); }
.q-text { font-weight: 600; margin: 0 0 10px; display: flex; gap: 8px; align-items: baseline; }
.q-id {
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); background: var(--line-soft);
  padding: 4px 6px; border-radius: 4px; letter-spacing: .04em;
}
.tag-qualifying {
  font-size: 10px; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
  color: var(--accent); background: var(--accent-soft);
  padding: 3px 7px; border-radius: 999px; white-space: nowrap;
}
.options { display: grid; gap: 6px; }
.option {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 8px;
  cursor: pointer; background: #fff;
}
.option:hover { border-color: #b9c4d6; background: #fcfdff; }
.option input { margin: 0; accent-color: var(--accent); }
.option span.label { flex: 1; }
.option .pts {
  font: 600 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); background: var(--line-soft); padding: 4px 6px; border-radius: 4px;
}
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option:has(input:checked) .pts { background: #dbe5ff; color: var(--accent); }

/* --- Sticky score bar --- */
.scorebar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  background: var(--ink); color: #fff;
  border-top: 3px solid var(--accent);
}
.scorebar-inner {
  max-width: 860px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; gap: 18px;
}
.scorebar .score-num { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }
.scorebar .score-num small { font-size: 13px; font-weight: 500; color: #93a2b8; }
.scorebar .progress-text { color: #b7c2d3; font-size: 13px; }
.scorebar .meter { flex: 1; height: 6px; background: #2b3a4d; border-radius: 99px; overflow: hidden; }
.scorebar .meter i { display: block; height: 100%; background: var(--accent); transition: width .18s ease; }
.scorebar .actions { display: flex; gap: 8px; align-items: center; }

/* --- Buttons --- */
.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  padding: 9px 16px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--line-soft); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #1740b0; }
.btn-ghost { background: transparent; border-color: #3d4d63; color: #d6dde8; }
.btn-ghost:hover { background: #2b3a4d; }
.btn-danger { color: var(--hot); border-color: #f3c4c0; background: #fff; }
.btn-danger:hover { background: var(--hot-bg); }

.btn-ms {
  width: 100%; justify-content: center; padding: 10px 16px;
  border-color: #8c8c8c; font-weight: 600;
}
.btn-ms:hover { background: #f3f3f3; }
.or-divider {
  display: flex; align-items: center; gap: 12px; margin: 16px 0;
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
}
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

/* --- Tier badges --- */
.tier {
  display: inline-block; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .07em;
  padding: 3px 9px; border-radius: 999px; border: 1px solid transparent;
}
.tier-Hot { color: var(--hot); background: var(--hot-bg); border-color: #fecdca; }
.tier-Warm { color: var(--warm); background: var(--warm-bg); border-color: #fedf89; }
.tier-Cold { color: var(--cold); background: var(--cold-bg); border-color: #d0d5dd; }
.scorebar .tier { font-size: 12px; padding: 4px 11px; }

/* --- Tiles --- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.tile {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.tile .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700;
}
.tile .v { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; }
.tile .v small { font-size: 14px; color: var(--muted); font-weight: 500; }
.tile-hot .v { color: var(--hot); }
.tile-warm .v { color: var(--warm); }

/* --- Toolbar --- */
.toolbar {
  display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap;
  margin-bottom: 14px;
}
.toolbar .field { min-width: 170px; }
.toolbar .spacer { flex: 1; }
.live-dot {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--muted);
}
.live-dot i {
  width: 7px; height: 7px; border-radius: 99px; background: var(--ok);
  box-shadow: 0 0 0 3px rgba(6, 118, 71, .14);
}
.live-dot.is-stale i { background: var(--muted); box-shadow: none; }

/* --- Table --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--panel); }
table.data th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line);
  white-space: nowrap; background: #fbfcfe;
}
table.data td { padding: 12px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
table.data tbody tr { cursor: pointer; }
table.data tbody tr:hover { background: #f8fafd; }
table.data tr.is-example td { color: var(--muted); }
table.data .num { font-variant-numeric: tabular-nums; }
.score-cell { display: flex; align-items: center; gap: 9px; white-space: nowrap; }
.score-cell b { font-variant-numeric: tabular-nums; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

/* --- Detail / report shared --- */
.record-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; flex-wrap: wrap;
}
.record-head .score-big { text-align: right; }
.score-big .n { font-size: 36px; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.score-big .n small { font-size: 16px; color: var(--muted); font-weight: 500; }
.meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 18px; }
.meta .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); font-weight: 700;
}
.meta .v { margin-top: 2px; word-break: break-word; }
.quote {
  border-left: 3px solid var(--accent); background: #fbfcff;
  padding: 12px 16px; border-radius: 0 8px 8px 0; white-space: pre-wrap;
}
.quote.is-empty { color: var(--muted); border-left-color: var(--line); font-style: italic; }

.bars { display: grid; gap: 10px; }
.bar-row { display: grid; grid-template-columns: 1fr 180px 62px; gap: 12px; align-items: center; }
.bar-row .name { font-weight: 600; }
.bar { height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-2); font-weight: 600; }
.bar.lvl-high i { background: var(--hot); }
.bar.lvl-mid i { background: var(--warm); }
.bar.lvl-low i { background: var(--cold); }

.answer-list { display: grid; gap: 0; }
.answer-row {
  display: grid; grid-template-columns: 1fr auto; gap: 16px;
  padding: 11px 0; border-top: 1px solid var(--line-soft); align-items: baseline;
}
.answer-row:first-child { border-top: none; }
.answer-row .q { color: var(--ink-2); }
.answer-row .a { font-weight: 600; }
.answer-row .a.is-blank { color: var(--muted); font-weight: 400; font-style: italic; }

/* Risk + Absolute recommendation for the option the rep selected (Build Spec §3.2). */
.answer-row .rec {
  margin-top: 6px; padding-left: 10px; border-left: 2px solid var(--line);
  font-size: 13px; color: var(--ink-2);
}
.risk-badge {
  display: inline-block; margin-right: 6px; vertical-align: 1px;
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  padding: 2px 7px; border-radius: 999px; border: 1px solid transparent;
}
.risk-crit { color: #fff; background: var(--hot); border-color: var(--hot); }
.risk-high { color: var(--hot); background: var(--hot-bg); border-color: #fecdca; }
.risk-mod  { color: var(--warm); background: var(--warm-bg); border-color: #fedf89; }
.risk-low  { color: var(--cold); background: var(--cold-bg); border-color: #d0d5dd; }
.answer-row .pts {
  font: 600 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted); background: var(--line-soft); padding: 5px 7px; border-radius: 4px;
  white-space: nowrap;
}
.section-score {
  font-size: 12px; color: var(--muted); font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.callout {
  border: 1px solid var(--line); border-left: 4px solid var(--accent);
  background: #fbfcff; border-radius: 0 8px 8px 0; padding: 14px 16px;
}
.callout .k {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em;
  color: var(--accent); font-weight: 700; margin-bottom: 4px;
}
.callout-Hot { border-left-color: var(--hot); background: var(--hot-bg); }
.callout-Hot .k { color: var(--hot); }
.callout-Warm { border-left-color: var(--warm); background: var(--warm-bg); }
.callout-Warm .k { color: var(--warm); }
.callout-Cold { border-left-color: var(--cold); background: var(--cold-bg); }
.callout-Cold .k { color: var(--cold); }

/* --- Save confirmation --- */
.confirm {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(19, 26, 36, .55);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.confirm-card {
  background: #fff; border-radius: 14px; padding: 28px; max-width: 420px; width: 100%;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .28); text-align: center;
}
.confirm-card .tick {
  width: 44px; height: 44px; border-radius: 99px; background: #ecfdf3; color: var(--ok);
  display: grid; place-items: center; margin: 0 auto 12px; font-size: 22px; font-weight: 700;
}
.confirm-card h2 { font-size: 18px; margin-bottom: 6px; }
.confirm-card .co { color: var(--muted); margin: 0 0 16px; }
.confirm-card .result {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  padding: 14px; background: var(--bg); border-radius: 10px; margin-bottom: 18px;
}
.confirm-card .result .n { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.confirm-card .result .n small { font-size: 14px; color: var(--muted); font-weight: 500; }
.confirm-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.btn-text-cancel {
  display: block; margin: 14px auto 0; padding: 4px;
  background: none; border: none; color: var(--muted); font: inherit;
  cursor: pointer; text-decoration: underline;
}
.btn-text-cancel:hover { color: var(--ink); }

.form-errors {
  background: var(--hot-bg); border: 1px solid #fecdca; color: var(--hot);
  border-radius: 8px; padding: 12px 14px; margin-bottom: 16px; font-weight: 500;
}

.report-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.subhead { color: var(--muted); font-size: 13px; margin: 0 0 12px; }

@media (max-width: 820px) {
  .grid, .grid-3 { grid-template-columns: 1fr; }
  .field.span-2 { grid-column: auto; }
  .tiles { grid-template-columns: repeat(2, 1fr); }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-row { grid-template-columns: 1fr 90px 56px; }
  .brand-sub, .internal-tag, .whoami { display: none; }
}

/* --- Report sheets (screen) --- */
.report-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: 20px; flex-wrap: wrap; margin-bottom: 18px;
}
.report-eyebrow {
  font-size: 11px; text-transform: uppercase; letter-spacing: .09em;
  color: var(--muted); font-weight: 700; margin-bottom: 4px;
}
.report-header h1 { margin-bottom: 2px; }
.report-footer {
  border-top: 1px solid var(--line); padding-top: 12px; margin-top: 8px;
  color: var(--muted); font-size: 12px;
}
.page-break { height: 0; }

/* --- Auth / sign-in split screen --- */
body.auth { background: #e9eeff; }
body.auth .topbar { display: none; }
.auth-main { max-width: none; margin: 0; padding: 0; }

.auth-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: linear-gradient(135deg, #d7e3ff 0%, #e5e1ff 46%, #f4e2ee 100%);
}

.auth-brand {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 64px clamp(40px, 6vw, 88px);
  color: #16224a;
}
.auth-brand::after {
  content: "";
  position: absolute;
  right: -140px; bottom: -160px;
  width: 420px; height: 420px;
  background: radial-gradient(circle, rgba(255, 255, 255, .55), rgba(255, 255, 255, 0) 70%);
  pointer-events: none;
}
.auth-brand > * { position: relative; z-index: 1; }

.auth-logo-row { display: flex; align-items: center; gap: 12px; margin-bottom: 34px; }
.auth-mark { color: var(--accent); display: inline-flex; }
.auth-brand-id { display: flex; flex-direction: column; gap: 4px; }
.auth-wordmark { font-weight: 800; font-size: 34px; line-height: 1; letter-spacing: .12em; }
.auth-fullform {
  font-size: 12px; font-weight: 600; letter-spacing: .1em;
  text-transform: uppercase; color: #45527e;
}

.auth-brand h2 {
  font-size: clamp(24px, 2.6vw, 32px);
  line-height: 1.2;
  letter-spacing: -.02em;
  margin: 0 0 16px;
  max-width: 16ch;
}
.auth-lede {
  font-size: 15px;
  line-height: 1.6;
  color: #3a4874;
  max-width: 40ch;
  margin: 0 0 34px;
}

.auth-points { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.auth-points li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  font-size: 14px;
  color: #26325c;
  max-width: 44ch;
}
.auth-points svg {
  flex: none;
  width: 20px; height: 20px;
  color: var(--accent);
  margin-top: 1px;
}

.auth-form-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 40px;
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: rgba(255, 255, 255, .72);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, .6);
  border-radius: 16px;
  box-shadow: 0 20px 50px -12px rgba(20, 30, 80, .28);
  padding: 32px 30px;
}
.auth-card h1 { font-size: 20px; margin: 0 0 4px; }
.auth-card .subhead { margin-bottom: 16px; }
.auth-card .btn-ms { background: #fff; }
.auth-card .btn-primary { width: 100%; justify-content: center; padding: 10px 16px; }

.auth-fields { display: grid; gap: 14px; }
.auth-actions { margin-top: 18px; }

@media (max-width: 860px) {
  .auth-split { grid-template-columns: 1fr; }
  .auth-brand {
    padding: 40px 28px 32px;
    justify-content: flex-start;
  }
  .auth-wordmark { font-size: 28px; }
  .auth-brand h2 { font-size: 22px; max-width: none; }
  .auth-lede { margin-bottom: 24px; }
  .auth-form-side { padding: 32px 24px 56px; }
}
