:root {
  --bg: #f6f7fb;
  --card: #fff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #1d4ed8;
  --accent-2: #1e3a8a;
  --good: #dcfce7;
  --good-ink: #166534;
  --reflect: #fef9c3;
  --reflect-ink: #854d0e;
  --attention: #fee2e2;
  --attention-ink: #991b1b;
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 2rem; letter-spacing: -.02em; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; margin-top: 1.2em; }
p { margin: 0 0 1em; }
code { background: #eef2ff; padding: 2px 6px; border-radius: 6px; font-size: .9em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
main { padding: 24px 16px 80px; margin: 0 auto; }
main.narrow { max-width: 680px; padding-top: 10vh; }
main.wide { max-width: 1180px; }
main.survey { max-width: 860px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: .4em; }
.eyebrow a { text-decoration: none; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 24px; margin: 0 0 20px; box-shadow: 0 1px 2px rgba(15,23,42,.04); }
.warn { background: var(--reflect); color: var(--reflect-ink); padding: 10px 14px; border-radius: 10px; }
.error { background: var(--attention); color: var(--attention-ink); padding: 10px 14px; border-radius: 10px; }
ul.cats { columns: 2; padding-left: 1.2em; }

/* buttons & forms */
button, .button {
  font: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 9px 16px; border-radius: 10px; text-decoration: none; display: inline-block;
}
button:hover, .button:hover { border-color: #cbd5e1; background: #f8fafc; }
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.danger { background: #fff; color: #b91c1c; border-color: #fecaca; margin-top: 14px; }
.danger:hover { background: #fef2f2; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 500; }
.danger-text { color: #b91c1c !important; }
input[type=text], input[type=number], input[type=password], input.copy {
  font: inherit; width: 100%; padding: 9px 12px; border: 1px solid #cbd5e1; border-radius: 10px; background: #fff; margin-top: 4px;
}
input.copy { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; background: #f8fafc; cursor: copy; min-width: 260px; }
label { display: block; font-weight: 600; font-size: .9rem; }
label.check { display: flex; gap: 8px; align-items: center; }
.grid-form { display: grid; grid-template-columns: 2fr 1fr; gap: 14px; align-items: end; }
.grid-form .span2 { grid-column: span 2; }
form.login { display: grid; gap: 14px; text-align: left; margin-top: 20px; }

/* topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 24px; background: #0f172a; color: #fff; }
.topbar .brand { color: #fff; font-weight: 800; text-decoration: none; letter-spacing: .02em; }
.topbar .brand span { font-weight: 400; opacity: .7; }
.topbar button.link { color: #cbd5e1; }

/* tables */
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.total td { font-weight: 700; border-top: 2px solid #cbd5e1; }
.scroll { overflow-x: auto; }
.b-good { background: var(--good); color: var(--good-ink); }
.b-reflect { background: var(--reflect); color: var(--reflect-ink); }
.b-attention { background: var(--attention); color: var(--attention-ink); }
td.b-good, td.b-reflect, td.b-attention { font-weight: 600; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: .78rem; font-weight: 600; background: #e2e8f0; color: #334155; white-space: nowrap; }

/* profile */
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.pagehead h1 { margin: 0; }
.manage .linkrow { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.manage .linkrow input { flex: 1; width: auto; margin: 0; }
.manage details { margin-top: 14px; }
details summary { cursor: pointer; font-weight: 600; color: var(--accent); }
details[open] summary { margin-bottom: 12px; }
.summary { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 16px; margin-bottom: 20px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; display: flex; flex-direction: column; gap: 4px; }
.stat .label { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.stat .value { font-size: 2.2rem; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat.big .value { font-size: 3rem; color: var(--accent); }
.stat .value.self { color: #e07a1f; }
.stat .sub { color: var(--muted); font-size: .88rem; }
.chart { width: 100%; height: auto; display: block; }
.radar { max-width: 760px; margin: 0 auto; }
.bars { max-width: 760px; margin: 0 auto 16px; }
.charts2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 24px; align-items: start; }
.legend { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 16px; font-size: .85rem; margin: 6px 0 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; }
.legend .zone { color: var(--muted); }
.legend .z-good { background: var(--good); border: 1px solid #86efac; }
.legend .z-reflect { background: var(--reflect); border: 1px solid #fde047; }
.legend .z-attention { background: var(--attention); border: 1px solid #fca5a5; }
.cols2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 32px; }
.cols2 h3 { margin-top: .4em; }
.cols2 ol, .cols2 ul { padding-left: 1.2em; margin: 0; }
.cols2 li { margin-bottom: 6px; }
.focus h3 .score, .interp h3 .score { color: var(--accent); font-variant-numeric: tabular-nums; }
.focus, .interp { border-top: 1px solid var(--line); padding-top: 6px; }
.focus:first-of-type, .interp:first-of-type { border-top: 0; }
.action { background: #eff6ff; border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; }
table.items td:nth-child(2) { width: 60%; }
th.dist, td.dist { width: 200px; }
.distbar { display: flex; height: 18px; border-radius: 5px; overflow: hidden; font-size: .7rem; font-weight: 700; color: #fff; }
.distbar span { display: flex; align-items: center; justify-content: center; min-width: 14px; }
.d1 { background: #dc2626; } .d2 { background: #f97316; } .d3 { background: #eab308; } .d4 { background: #84cc16; } .d5 { background: #16a34a; }
table.matrix td { padding: 4px 6px; font-size: .82rem; }
table.matrix tr.grouphead td { background: #f1f5f9; font-weight: 700; }
.v1 { background: #fee2e2; } .v2 { background: #ffedd5; } .v3 { background: #fef9c3; } .v4 { background: #ecfccb; } .v5 { background: #dcfce7; }

/* survey */
.hero { padding: 20px 4px 8px; }
.hero h1 { font-size: 2.2rem; margin-bottom: .2em; }
.hero .notes { color: var(--muted); font-weight: 600; }
.rels { display: grid; gap: 8px; }
label.rel { display: flex; gap: 10px; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; cursor: pointer; font-weight: 500; }
label.rel:has(input:checked) { border-color: var(--accent); background: #eff6ff; }
.scale-key { display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: center; font-size: .85rem; color: var(--muted); margin: 0 0 20px; position: sticky; top: 0; background: var(--bg); padding: 10px 0; z-index: 5; }
.category .question { font-style: italic; color: #334155; }
.category .this { font-weight: 700; margin-bottom: .4em; }
ol.items { list-style: none; padding: 0; margin: 0; counter-reset: item; }
ol.items li { counter-increment: item; display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--line); }
ol.items li .stmt::before { content: counter(item) ". "; color: var(--muted); font-weight: 600; }
ol.items li.missing { background: #fff7ed; }
.scale { display: inline-flex; flex-shrink: 0; border-radius: 10px; overflow: hidden; border: 1px solid #cbd5e1; }
.scale label { position: relative; margin: 0; }
.scale input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.scale span { display: block; width: 44px; height: 40px; line-height: 40px; text-align: center; font-weight: 700; color: #475569; background: #fff; border-left: 1px solid #e2e8f0; transition: background .12s; }
.scale label:first-child span { border-left: 0; }
.scale label:hover span { background: #f1f5f9; }
.scale input:focus-visible + span { outline: 3px solid #93c5fd; outline-offset: -3px; }
/* Shade boxes up to the chosen score, like the paper booklet */
.scale:has(input[value="1"]:checked) label:nth-child(-n+1) span,
.scale:has(input[value="2"]:checked) label:nth-child(-n+2) span,
.scale:has(input[value="3"]:checked) label:nth-child(-n+3) span,
.scale:has(input[value="4"]:checked) label:nth-child(-n+4) span,
.scale:has(input[value="5"]:checked) label:nth-child(-n+5) span { background: #bfdbfe; color: #1e3a8a; }
.scale input:checked + span { background: var(--accent) !important; color: #fff !important; }
.submitbar { position: sticky; bottom: 0; display: flex; align-items: center; gap: 14px; background: rgba(255,255,255,.96); backdrop-filter: blur(6px); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; box-shadow: 0 -4px 20px rgba(15,23,42,.06); }
.progress { flex: 1; height: 8px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.progress .bar { height: 100%; width: 0; background: var(--accent); transition: width .2s; }
#progress-text { font-size: .85rem; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* report / print */
.printbar { position: sticky; top: 0; display: flex; gap: 16px; align-items: center; padding: 12px 24px; background: #0f172a; color: #cbd5e1; z-index: 10; }
.printbar .muted { color: #94a3b8; }
main.report { max-width: 960px; }
.cover { padding: 40px 0 20px; }
.cover h1 { font-size: 2.6rem; margin-bottom: .1em; }
.cover .big { font-size: 1.6rem; color: var(--muted); font-weight: 700; }
table.plan td { height: 46px; border: 1px solid #cbd5e1; }
table.plan td:first-child { width: 80px; font-weight: 600; }
table.plan td:nth-child(3), table.plan td:nth-child(4) { width: 130px; }
ol.lines li { border-bottom: 1px solid #cbd5e1; height: 36px; }
.sign { margin-top: 30px; }

@media (max-width: 720px) {
  h1 { font-size: 1.6rem; }
  .summary, .cols2, .grid-form { grid-template-columns: 1fr; }
  .grid-form .span2 { grid-column: auto; }
  .card { padding: 16px; }
  ol.items li { flex-direction: column; align-items: stretch; gap: 8px; }
  .scale { align-self: stretch; }
  .scale label { flex: 1; }
  .scale span { width: auto; }
  .charts2 { grid-template-columns: 1fr; }
  ul.cats { columns: 1; }
  th.dist, td.dist { width: 120px; }
}

@media print {
  @page { size: A4; margin: 14mm; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  body { background: #fff; font-size: 11pt; }
  .noprint, .printbar, details, .manage { display: none !important; }
  main { padding: 0; max-width: none !important; }
  .card { border: 0; box-shadow: none; padding: 0; margin-bottom: 18px; }
  .stat { border: 1px solid var(--line); }
  .pagebreak { break-before: page; }
  .keep, .focus, .interp, tr { break-inside: avoid; }
  h2, h3 { break-after: avoid; }
  .scroll { overflow: visible; }
  a { color: inherit; text-decoration: none; }
  .summary { grid-template-columns: 2fr 1fr 1fr; }
  .charts2 { grid-template-columns: 1fr 1fr; }
  .radar { max-width: 560px; }
  table { font-size: 9pt; }
  table.indiv th, table.indiv td { padding: 4px 4px; font-size: 7.5pt; }
}
