:root {
  --bg: #f7f3eb;
  --surface: #fffdf7;
  --surface-strong: #eef3ea;
  --navy: #17273b;
  --text: #273244;
  --muted: #5f6b77;
  --sage: #7d927d;
  --sage-dark: #536c58;
  --line: #d7d3c8;
  --warning-bg: #fff4df;
  --warning-border: #c89242;
  --danger: #9f362d;
  --focus: #1d5d8f;
  --shadow: 0 16px 40px rgba(23, 39, 59, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.55;
}

button,
input {
  font: inherit;
}

a {
  color: var(--sage-dark);
}

a:hover {
  color: var(--navy);
}

.wrap {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -80px;
  z-index: 20;
  padding: 10px 14px;
  background: var(--navy);
  color: #fff;
}

.skip-link:focus {
  top: 16px;
}

.site-header {
  padding: 54px 0 34px;
  background: linear-gradient(180deg, #fffdf7 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--sage-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
legend {
  color: var(--navy);
  line-height: 1.2;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  letter-spacing: 0;
}

h2 {
  margin: 0 0 14px;
  font-size: 1.35rem;
}

h3,
legend {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
}

.subtitle {
  margin: 14px 0 0;
  color: var(--sage-dark);
  font-size: 1.2rem;
  font-weight: 700;
}

.intro {
  max-width: 760px;
  margin: 18px 0 0;
  font-size: 1.05rem;
}

.status-note,
.notice,
.client-panel,
.progress-box,
.summary-section,
.history-panel,
.history-detail {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status-note {
  display: inline-block;
  margin: 24px 0 0;
  padding: 10px 14px;
  box-shadow: none;
  font-weight: 700;
}

.notice,
.client-panel,
.summary-section,
.history-panel,
.history-detail {
  margin-top: 28px;
  padding: 24px;
}

.notice {
  background: var(--surface-strong);
}

.notice p,
.summary-section p,
.history-panel p {
  margin: 0;
}

.history-header,
.history-detail-header {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
}

.history-content {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.history-list:not(:empty) {
  margin-top: 12px;
}

.history-list button {
  display: flex;
  width: 100%;
  min-height: 54px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-color: var(--line);
  background: #fff;
  color: var(--navy);
  text-align: left;
}

.history-list span {
  color: var(--muted);
  font-weight: 400;
}

.history-detail dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 0 0 22px;
}

.history-detail dt {
  color: var(--navy);
  font-weight: 700;
}

.history-detail dd {
  margin: 0;
}

.saved-section {
  margin-top: 20px;
}

.saved-section h3 {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.saved-section ol {
  margin: 10px 0 0;
  padding-left: 22px;
}

.saved-section li {
  margin-top: 8px;
}

.client-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--navy);
  font-weight: 700;
}

input[type="text"],
input[type="date"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

.progress-box {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 24px 0;
  padding: 16px;
}

.progress-track {
  width: 100%;
  height: 10px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e3ded2;
}

#progress-bar {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--sage);
  transition: width 160ms ease;
}

.section-card {
  margin: 24px 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.section-card > h2 {
  padding-bottom: 12px;
  border-bottom: 2px solid var(--sage);
}

.question {
  margin: 18px 0 0;
  padding: 18px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.question:first-of-type {
  border-top: 0;
}

.option-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.radio-option {
  min-height: 48px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.radio-option input {
  width: 18px;
  height: 18px;
  margin: 0 8px 0 0;
  vertical-align: middle;
  accent-color: var(--sage-dark);
}

.radio-option:has(input:checked) {
  border-color: var(--sage-dark);
  background: var(--surface-strong);
  color: var(--navy);
  font-weight: 700;
}

.missing-alert {
  margin: 0 0 20px;
  padding: 16px;
  border: 1px solid var(--danger);
  border-radius: 8px;
  background: #fff8f6;
  color: var(--danger);
  font-weight: 700;
}

.missing-list,
.answer-list {
  margin: 10px 0 0;
  padding-left: 22px;
}

.guidance {
  margin-top: 18px;
  padding: 16px;
  border-left: 4px solid var(--sage-dark);
  background: var(--surface-strong);
}

.safeguarding {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--warning-border);
  border-radius: 8px;
  background: var(--warning-bg);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
  margin: 28px 0 46px;
}

button {
  min-height: 46px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 10px 18px;
  cursor: pointer;
  font-weight: 700;
}

.primary-button {
  background: var(--navy);
  color: #fff;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  border-color: var(--line);
  background: #fff;
  color: var(--navy);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
}

.footer-inner {
  display: flex;
  gap: 22px;
  align-items: center;
  justify-content: space-between;
  padding: 24px 0;
}

.footer-inner span,
address a {
  display: block;
}

address {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  justify-content: flex-end;
  font-style: normal;
}

@media (max-width: 720px) {
  .wrap {
    width: min(100% - 24px, 1080px);
  }

  .site-header {
    padding: 38px 0 26px;
  }

  .client-grid,
  .option-row {
    grid-template-columns: 1fr;
  }

  .notice,
  .client-panel,
  .section-card,
  .summary-section,
  .history-panel,
  .history-detail {
    padding: 18px;
  }

  .history-header,
  .history-detail-header,
  .history-list button {
    display: block;
  }

  .history-header button,
  .history-detail-header button {
    width: 100%;
    margin-top: 14px;
  }

  .history-detail dl {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  .footer-inner,
  address {
    display: block;
  }

  address {
    margin-top: 12px;
  }

  .actions {
    display: grid;
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  :root {
    --bg: #fff;
    --surface: #fff;
    --surface-strong: #fff;
    --navy: #000;
    --text: #000;
    --muted: #000;
    --line: #999;
    --shadow: none;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 10.5pt;
    line-height: 1.35;
  }

  .skip-link,
  .progress-box,
  .actions,
  .history-panel,
  .history-detail-header,
  .missing-alert,
  input,
  .option-row {
    display: none !important;
  }

  .wrap {
    width: 100%;
  }

  .site-header {
    padding: 0 0 8mm;
    border-bottom: 1px solid #999;
  }

  h1 {
    font-size: 20pt;
  }

  h2 {
    margin-bottom: 3mm;
    font-size: 13pt;
  }

  legend,
  h3 {
    font-size: 10.5pt;
  }

  .subtitle,
  .intro,
  .status-note {
    margin-top: 3mm;
  }

  .notice,
  .client-panel,
  .section-card,
  .summary-section,
  .history-detail {
    margin-top: 5mm;
    padding: 0;
    border: 0;
    box-shadow: none;
  }

  .client-panel::after {
    content: "Client name: " attr(data-print-client) "\A Assessment date: " attr(data-print-date);
    display: block;
    white-space: pre-line;
    border: 1px solid #999;
    padding: 3mm;
  }

  .client-grid {
    display: none;
  }

  .section-card > h2 {
    padding-bottom: 2mm;
    border-bottom: 1px solid #999;
  }

  .question {
    break-inside: avoid;
    margin-top: 3mm;
    padding-top: 2mm;
  }

  .question::after {
    content: "Answer: " attr(data-answer);
    display: block;
    margin-top: 1mm;
    font-weight: 700;
  }

  .summary-section[hidden] {
    display: block;
  }

  .guidance,
  .safeguarding {
    margin-top: 3mm;
    padding: 2mm;
    border: 1px solid #999;
    background: #fff;
  }

  .site-footer {
    margin-top: 8mm;
    border-top: 1px solid #999;
  }

  .footer-inner {
    display: block;
    padding: 4mm 0 0;
  }

  address {
    display: block;
    margin-top: 2mm;
  }
}
