:root {
  --ink: #111111;
  --paper: #f4f1e8;
  --surface: #fffdf7;
  --muted: #67645d;
  --line: #111111;
  --accent: #ffdf3f;
  --danger: #b42318;
  --ok: #176b3a;
  --shadow: 5px 5px 0 #111111;
  color-scheme: light;
  font-family: Arial, Helvetica, sans-serif;
}
* { box-sizing: border-box; }
.section-card, .document-card, .question-card, .review-card, .question-text, p, h1, h2, h3 { overflow-wrap: anywhere; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); min-width: 320px; }
button, input, textarea, select { font: inherit; }
button, select, input[type="checkbox"], input[type="radio"] { cursor: pointer; }
input, textarea, select { width: 100%; border: 2px solid var(--line); border-radius: 0; padding: .72rem .8rem; background: #fff; color: var(--ink); }
textarea { resize: vertical; min-height: 5.3rem; line-height: 1.45; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
fieldset { border: 2px solid var(--line); padding: 1rem; margin: 0; }
legend { font-weight: 800; padding: 0 .45rem; }
label { display: grid; gap: .42rem; font-weight: 700; font-size: .9rem; }
.skip-link { position: fixed; top: -100px; left: 1rem; background: var(--accent); padding: .7rem; z-index: 999; color: #000; font-weight: 800; }
.skip-link:focus { top: 1rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 3px solid var(--line); padding: 1rem clamp(1rem, 3vw, 2.5rem); background: var(--surface); position: sticky; top: 0; z-index: 30; }
.topbar h1 { margin: 0; font-size: clamp(1.2rem, 3vw, 2rem); text-transform: uppercase; letter-spacing: -.04em; }
.topbar-actions, .button-row, .hero-actions, .section-controls { display: flex; align-items: center; gap: .7rem; flex-wrap: wrap; }
.primary-nav { display: flex; gap: 0; overflow-x: auto; background: var(--ink); padding: 0 clamp(.5rem, 2vw, 2rem); }
.nav-tab { border: 0; border-right: 1px solid #555; color: white; background: transparent; padding: .9rem 1rem; white-space: nowrap; font-weight: 800; }
.nav-tab.active { color: var(--ink); background: var(--accent); }
main { width: min(1500px, 100%); margin: 0 auto; padding: clamp(1rem, 3vw, 2.5rem); min-height: 75vh; }
.view { display: none; }
.view.active { display: block; }
.panel { background: var(--surface); border: 3px solid var(--line); padding: clamp(1rem, 2.5vw, 1.6rem); box-shadow: var(--shadow); margin-bottom: 1.25rem; }
.panel.compact { padding: 1rem; box-shadow: 3px 3px 0 var(--line); }
.hero { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(260px, .8fr); gap: 2rem; align-items: stretch; }
.hero h2 { font-size: clamp(2rem, 5.5vw, 4.8rem); line-height: .95; letter-spacing: -.065em; margin: .3rem 0 1rem; max-width: 15ch; }
.lead { max-width: 70ch; font-size: clamp(1rem, 2vw, 1.2rem); line-height: 1.55; }
.hero-stats { margin: 0; display: grid; grid-template-columns: 1fr 1fr; border: 3px solid var(--line); background: var(--accent); }
.hero-stats div { padding: 1rem; border-right: 2px solid var(--line); border-bottom: 2px solid var(--line); }
.hero-stats dt { font-size: clamp(2rem, 5vw, 4rem); font-weight: 900; line-height: 1; }
.hero-stats dd { margin: .35rem 0 0; font-weight: 700; }
.eyebrow { margin: 0 0 .35rem; font-size: .72rem; letter-spacing: .14em; font-weight: 900; text-transform: uppercase; color: var(--muted); }
.section-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; margin-bottom: 1.2rem; }
.section-heading h2 { margin: 0; font-size: clamp(1.7rem, 3.5vw, 3rem); line-height: 1; letter-spacing: -.045em; }
.required-note, .save-state, .badge { font-size: .75rem; font-weight: 800; border: 2px solid var(--line); padding: .35rem .5rem; background: var(--accent); }
.save-state { background: #fff; }
.button { border: 3px solid var(--line); background: var(--accent); color: var(--ink); padding: .7rem 1rem; font-weight: 900; box-shadow: 3px 3px 0 var(--line); text-decoration: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; }
.button:hover { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--line); }
.button.secondary { background: #fff; }
.button.danger { background: #ffd7d2; color: #5f0b04; }
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.full-span { grid-column: 1 / -1; }
.check-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: .55rem; }
.check-option, .toggle { display: flex; align-items: flex-start; gap: .55rem; font-weight: 700; }
.check-option input, .toggle input { width: auto; margin-top: .15rem; }
.summary-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.summary-card { border: 3px solid var(--line); padding: 1rem; background: var(--surface); box-shadow: 4px 4px 0 var(--line); }
.summary-card strong { display: block; font-size: clamp(1.8rem, 4vw, 3rem); line-height: 1; }
.summary-card span { display: block; margin-top: .45rem; color: var(--muted); font-weight: 700; }
.toolbar { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; }
.toolbar label { min-width: min(260px, 100%); flex: 1; }
.section-grid, .document-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.section-card, .document-card { border: 3px solid var(--line); background: var(--surface); padding: 1rem; box-shadow: 4px 4px 0 var(--line); display: flex; flex-direction: column; gap: .75rem; }
.section-card h3, .document-card h3 { margin: 0; font-size: 1.1rem; line-height: 1.15; }
.card-meta { display: flex; justify-content: space-between; align-items: center; gap: .5rem; color: var(--muted); font-size: .82rem; font-weight: 700; }
.progress-track { height: .8rem; border: 2px solid var(--line); background: #fff; }
.progress-fill { height: 100%; background: var(--accent); width: 0; }
.questionnaire-layout { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.section-sidebar { position: sticky; top: 8.5rem; max-height: calc(100vh - 10rem); overflow: auto; border: 3px solid var(--line); background: var(--surface); }
.sidebar-head { position: sticky; top: 0; z-index: 3; background: var(--surface); padding: 1rem; border-bottom: 3px solid var(--line); }
.section-nav-button { width: 100%; text-align: left; border: 0; border-bottom: 1px solid #aaa; background: transparent; padding: .75rem; display: grid; gap: .25rem; }
.section-nav-button.active { background: var(--accent); }
.section-nav-button strong { font-size: .85rem; }
.section-nav-button span { font-size: .75rem; color: var(--muted); }
.sticky-heading { position: sticky; top: 6.7rem; z-index: 8; background: var(--paper); padding: .5rem 0; }
.question-card { border: 3px solid var(--line); background: var(--surface); margin-bottom: 1rem; box-shadow: 4px 4px 0 var(--line); }
.question-main { padding: 1rem; }
.question-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: .75rem; }
.question-id { font-weight: 900; font-size: .85rem; background: var(--accent); border: 2px solid var(--line); padding: .28rem .4rem; white-space: nowrap; }
.question-text { font-size: 1.02rem; line-height: 1.45; margin: 0; flex: 1; }
.question-toolbar { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .75rem; margin-top: .85rem; }
.question-details { border-top: 2px solid var(--line); padding: 1rem; background: #f9f7ef; }
.question-details summary { font-weight: 900; cursor: pointer; }
.metadata-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .75rem; margin-top: 1rem; }
.confidence-group { display: flex; flex-wrap: wrap; gap: .35rem; }
.confidence-group label { display: inline-flex; align-items: center; gap: .2rem; border: 2px solid var(--line); padding: .35rem .5rem; background: #fff; }
.confidence-group input { width: auto; }
.pager { display: flex; justify-content: space-between; }
.validation-ok { border-left: 8px solid var(--ok); }
.validation-warn { border-left: 8px solid #d97706; }
.review-card { border: 2px solid var(--line); background: var(--surface); margin-bottom: .75rem; }
.review-card summary { cursor: pointer; padding: 1rem; font-weight: 800; }
.review-body { border-top: 2px solid var(--line); padding: 1rem; display: grid; gap: .55rem; }
.review-body p { margin: 0; line-height: 1.45; }
.document-card p { margin: 0; color: var(--muted); line-height: 1.45; flex: 1; }
.privacy-banner { box-shadow: none; background: #fff9c7; }
.status-log { margin-top: 1rem; min-height: 2rem; font-weight: 700; }
.settings-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.danger-panel { background: #fff1ef; }
.file-button input { position: absolute; opacity: 0; pointer-events: none; width: 1px; height: 1px; }
.plain-list { margin: 0; padding-left: 1.2rem; line-height: 1.7; }
.muted { color: var(--muted); }
.empty-state { text-align: center; padding: 2rem; border: 3px dashed var(--line); background: #fff; }
.hidden { display: none !important; }
footer { border-top: 3px solid var(--line); background: var(--ink); color: #fff; padding: 1.2rem clamp(1rem, 3vw, 2.5rem); display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-weight: 700; }
dialog { border: 3px solid var(--line); padding: 0; max-width: 520px; width: calc(100% - 2rem); box-shadow: 8px 8px 0 var(--line); }
dialog::backdrop { background: rgba(0,0,0,.55); }
.dialog-card { padding: 1.5rem; }
.dialog-card h2 { margin-top: 0; }
.end { justify-content: flex-end; }
@media (max-width: 1100px) {
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .check-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .section-grid, .document-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .summary-cards { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .questionnaire-layout { grid-template-columns: 270px minmax(0,1fr); }
}
@media (max-width: 760px) {
  .topbar { position: static; align-items: flex-start; }
  .save-state { display: none; }
  main { padding: 1rem; }
  .hero, .settings-grid, .questionnaire-layout { grid-template-columns: 1fr; }
  .hero h2 { max-width: none; }
  .form-grid, .section-grid, .document-grid, .metadata-grid, .question-toolbar { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .section-sidebar { position: static; max-height: 280px; }
  .sticky-heading { position: static; }
  .section-heading { align-items: flex-start; flex-direction: column; }
  .full-span { grid-column: auto; }
}
@media (max-width: 440px) {
  .summary-cards, .hero-stats, .check-grid { grid-template-columns: 1fr; }
  .topbar-actions .button { padding: .55rem .7rem; }
  .question-head { flex-direction: column; }
  .pager { gap: .6rem; }
  .pager .button { flex: 1; }
}
@media print {
  .topbar, .primary-nav, footer, .button, .section-sidebar { display: none !important; }
  body { background: white; }
  main { width: 100%; padding: 0; }
  .panel, .question-card { box-shadow: none; break-inside: avoid; }
}
