:root {
  --bg: #f3f6f5;
  --surface: #ffffff;
  --surface-muted: #eef3f1;
  --text: #18201d;
  --muted: #58635f;
  --border: #d6dfdb;
  --primary: #116149;
  --primary-dark: #0b4937;
  --teal: #238b83;
  --amber: #b66a09;
  --red: #b42318;
  --green-soft: #e5f3ed;
  --amber-soft: #fff2d8;
  --red-soft: #fee9e7;
  --shadow: 0 8px 24px rgba(20, 39, 32, 0.08);
  font-family: Inter, Aptos, "Segoe UI", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, select { cursor: pointer; }
a { color: var(--primary); }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 30px; line-height: 1.16; margin-bottom: 8px; }
h2 { font-size: 22px; line-height: 1.25; margin-bottom: 8px; }
h3 { font-size: 16px; line-height: 1.35; margin-bottom: 14px; }

.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.header-inner { max-width: 1040px; margin: 0 auto; padding: 18px 24px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.header-inner > div { display: flex; align-items: baseline; gap: 10px; }
.header-inner strong { font-size: 18px; }
.header-inner span, .quiet-link { color: var(--muted); font-size: 14px; }
.quiet-link { text-decoration: none; }
.public-nav { display: flex; gap: 20px; }
.public-nav a { color: var(--muted); text-decoration: none; font-weight: 650; padding: 6px 0; border-bottom: 2px solid transparent; }
.public-nav a.active { color: var(--primary-dark); border-bottom-color: var(--primary); }

.survey-shell { max-width: 1040px; margin: 34px auto 60px; padding: 0 24px; }
.survey-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 18px; }
.survey-heading p { color: var(--muted); margin-bottom: 0; }
.step-count { color: var(--muted); white-space: nowrap; font-weight: 600; }
.progress-track { height: 7px; background: #dfe7e4; overflow: hidden; margin-bottom: 20px; }
.progress-fill { height: 100%; width: 25%; background: var(--primary); transition: width 180ms ease; }
.privacy-notice { background: var(--green-soft); border-left: 4px solid var(--primary); padding: 16px 18px; margin-bottom: 22px; }
.privacy-notice strong { display: block; color: var(--primary-dark); margin-bottom: 4px; }
.privacy-notice p { margin: 0; color: #355148; }
.privacy-notice.compact { margin-top: 22px; }

#survey-form { background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); }
.survey-step { display: none; padding: 30px; }
.survey-step.active { display: block; }
.section-intro { border-bottom: 1px solid var(--border); padding-bottom: 18px; margin-bottom: 24px; }
.section-intro > span { display: block; color: var(--primary); font-size: 13px; font-weight: 700; text-transform: uppercase; margin-bottom: 6px; }
.section-intro p { color: var(--muted); margin-bottom: 0; }
.form-grid { display: grid; gap: 18px; }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field > span, legend { font-weight: 650; color: #26312d; }
.field small, .field-help { color: var(--muted); font-size: 13px; }
.field.wide { grid-column: 1 / -1; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"], input[type="file"], select, textarea {
  width: 100%; border: 1px solid #bfcac5; border-radius: 5px; background: var(--surface); color: var(--text); padding: 11px 12px; min-height: 44px;
}
textarea { resize: vertical; min-height: 120px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(35, 139, 131, 0.24); outline-offset: 1px; border-color: var(--teal); }
input.invalid, select.invalid { border-color: var(--red); background: #fff8f7; }
.field-block { border: 0; margin: 25px 0 0; padding: 0; }
.field-block legend { padding: 0; margin-bottom: 4px; }
.choice-row { display: flex; gap: 12px; margin-top: 12px; }
.choice-stack { display: grid; gap: 10px; margin-top: 12px; }
.radio-option, .check-option { display: flex; gap: 9px; align-items: flex-start; color: #34403b; }
.radio-option { border: 1px solid var(--border); border-radius: 5px; padding: 12px 16px; min-width: 160px; background: #fafcfb; }
.radio-option input, .check-option input, .consent-line input { margin: 3px 0 0; width: 17px; height: 17px; accent-color: var(--primary); flex: 0 0 auto; }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 22px; margin-top: 12px; }
.consent-line { display: flex; gap: 10px; padding: 16px; background: var(--surface-muted); margin-top: 26px; }
.form-actions { border-top: 1px solid var(--border); padding: 18px 30px; display: flex; justify-content: flex-end; gap: 10px; background: #fafcfb; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; border-radius: 5px; border: 1px solid transparent; padding: 9px 16px; text-decoration: none; font-weight: 650; white-space: nowrap; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { background: var(--surface); border-color: #9fb2aa; color: var(--primary-dark); }
.button.ghost { background: transparent; color: var(--muted); }
.button.full { width: 100%; margin-top: 8px; }
.tool-entry { border-top: 4px solid var(--primary); background: #fbfcfc; padding: 22px; margin: 0 0 20px; box-shadow: inset 0 0 0 1px var(--border); }
.tool-entry-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.tool-entry-header > div { display: flex; align-items: baseline; gap: 10px; }
.tool-entry-header h3 { margin: 0; font-size: 19px; }
.tool-number { color: var(--primary); font-size: 13px; font-weight: 750; text-transform: uppercase; }
.icon-button { border: 0; background: transparent; color: var(--muted); font-size: 25px; width: 38px; height: 38px; line-height: 1; }
#add-tool { margin-top: 2px; }
.info-panel { padding: 18px; background: var(--surface-muted); border: 1px solid var(--border); margin-bottom: 18px; }
.info-panel p { margin: 4px 0 0; color: var(--muted); }
.review-summary { border-top: 1px solid var(--border); }
.review-summary > div { display: grid; grid-template-columns: 180px 1fr; gap: 18px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.review-summary span { color: var(--muted); }
.alert { padding: 13px 15px; margin: 0 0 18px; border: 1px solid; }
.alert.error { color: #7a271a; background: var(--red-soft); border-color: #f0aaa3; }
.alert.success { color: var(--primary-dark); background: var(--green-soft); border-color: #8fc7b1; }
.hidden { display: none !important; }
.honeypot { position: absolute !important; left: -10000px !important; width: 1px !important; height: 1px !important; overflow: hidden !important; }

.completion-shell, .auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px 20px; }
.completion-panel, .auth-panel { width: min(100%, 520px); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); padding: 34px; }
.completion-panel { text-align: center; }
.completion-panel p, .auth-panel > p { color: var(--muted); }
.success-mark { width: 52px; height: 52px; display: grid; place-items: center; margin: 0 auto 18px; border-radius: 50%; background: var(--green-soft); color: var(--primary); font-size: 28px; font-weight: 800; }
.auth-panel form { display: grid; gap: 17px; margin-top: 24px; }
.back-link { display: block; text-align: center; margin-top: 18px; }
.requirements { margin: 20px 0; border-top: 1px solid var(--border); }
.requirement { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--border); }
.requirement.pass span { color: var(--primary); }
.requirement.fail { color: var(--red); }

.report-header { min-height: 68px; padding: 12px 28px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; gap: 20px; position: sticky; top: 0; z-index: 10; }
.report-header > div:first-child { display: flex; flex-direction: column; }
.report-header strong { font-size: 13px; color: var(--primary); }
.report-header span { font-size: 20px; font-weight: 750; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.header-actions form { margin: 0; }
.admin-tabs { display: flex; align-items: center; gap: 6px; }
.admin-tabs a { color: var(--muted); text-decoration: none; font-weight: 650; padding: 9px 12px; border-bottom: 2px solid transparent; }
.admin-tabs a.active { color: var(--primary-dark); border-bottom-color: var(--primary); }
.report-shell { max-width: 1480px; padding: 28px; margin: 0 auto; }
.report-actions { display: flex; gap: 8px; justify-content: flex-end; margin: -4px 0 12px; }
.report-title { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 20px; }
.report-title p { color: var(--muted); margin: 0; }
.report-title > span { color: var(--muted); font-size: 13px; white-space: nowrap; }
.filter-bar { display: grid; grid-template-columns: 150px 150px minmax(180px, 1fr) minmax(180px, 1fr) minmax(160px, 1fr) auto auto; gap: 10px; align-items: end; background: var(--surface); border: 1px solid var(--border); padding: 14px; margin-bottom: 18px; }
.filter-bar label { display: grid; gap: 4px; }
.filter-bar label span { font-size: 12px; color: var(--muted); font-weight: 650; }
.filter-bar input, .filter-bar select { min-height: 40px; padding: 8px 9px; }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.metric-strip > div { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--primary); padding: 17px; min-height: 122px; display: flex; flex-direction: column; }
.metric-strip span { color: var(--muted); font-weight: 600; }
.metric-strip strong { font-size: 34px; line-height: 1.2; margin-top: 9px; }
.metric-strip small { color: var(--muted); }
.metric-strip .risk-number { color: var(--amber); }
.report-nav { display: flex; gap: 26px; background: var(--surface); border: 1px solid var(--border); padding: 13px 18px; position: sticky; top: 68px; z-index: 9; overflow-x: auto; }
.report-nav a { color: var(--text); text-decoration: none; font-weight: 650; white-space: nowrap; }
.report-section { padding: 34px 0 6px; scroll-margin-top: 130px; }
.section-heading { margin-bottom: 16px; }
.section-heading p { color: var(--muted); margin: 0; max-width: 900px; }
.report-grid { display: grid; gap: 14px; }
.report-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.report-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.chart-panel { background: var(--surface); border: 1px solid var(--border); padding: 18px; min-width: 0; }
.bar-row { margin-bottom: 11px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; font-size: 13px; }
.bar-label span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-label strong { white-space: nowrap; }
.bar-label small { color: var(--muted); font-weight: 500; }
.bar-row progress { display: block; width: 100%; height: 7px; border: 0; margin-top: 4px; background: #e6ece9; appearance: none; }
.bar-row progress::-webkit-progress-bar { background: #e6ece9; }
.bar-row progress::-webkit-progress-value { background: var(--teal); }
.bar-row progress::-moz-progress-bar { background: var(--teal); }
.subheading { border-top: 1px solid var(--border); padding-top: 18px; margin-top: 22px; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); margin-top: 14px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { background: var(--surface-muted); font-size: 12px; color: #39453f; }
.risk-badge { display: inline-block; min-width: 66px; padding: 3px 8px; border-radius: 4px; text-align: center; font-weight: 700; }
.risk-badge.low { background: var(--green-soft); color: var(--primary-dark); }
.risk-badge.medium { background: var(--amber-soft); color: #7a4300; }
.risk-badge.high { background: var(--red-soft); color: var(--red); }
.suppressed { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--amber); padding: 26px; }
.suppressed p { margin-bottom: 0; color: var(--muted); }
.admin-title { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 18px; }
.admin-title p, .muted { color: var(--muted); margin-bottom: 0; }
.admin-title > span { color: var(--muted); white-space: nowrap; }
.admin-panel { background: var(--surface); border: 1px solid var(--border); padding: 22px; margin-bottom: 16px; }
.question-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: end; }
.question-form .wide { grid-column: 1 / -1; }
.question-form .button { justify-self: start; }
.question-card.inactive { opacity: 0.76; }
.question-card-heading { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: center; gap: 16px; border-bottom: 1px solid var(--border); padding-bottom: 12px; }
.question-card-heading > div { display: flex; gap: 10px; align-items: baseline; }
.question-card-heading > div span { color: var(--primary); font-size: 12px; font-weight: 750; text-transform: uppercase; }
.status-badge { display: inline-block; padding: 3px 8px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.status-badge.active { color: var(--primary-dark); background: var(--green-soft); }
.status-badge.inactive { color: var(--muted); background: var(--surface-muted); }
.question-status-form { margin-top: 10px; border-top: 1px solid var(--border); padding-top: 8px; }
.update-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, .6fr); gap: 16px; }
.update-form { display: grid; gap: 16px; margin-top: 18px; }
.security-list { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.security-list span { background: var(--green-soft); color: var(--primary-dark); padding: 9px 11px; font-size: 13px; }
.rollback-form { display: flex; gap: 10px; align-items: center; }
.text-responses p { padding: 9px 0; border-bottom: 1px solid var(--border); margin: 0; color: #34403b; }
.custom-question-list { display: grid; gap: 22px; }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--border); padding-bottom: 14px; margin-bottom: 18px; }
.panel-heading h2, .panel-heading p { margin-bottom: 0; }
.panel-heading p { color: var(--muted); }
.status-badge.approved, .status-badge.published { background: var(--green-soft); color: var(--primary-dark); }
.status-badge.conditional { background: var(--amber-soft); color: #7a4300; }
.status-badge.blocked { background: var(--red-soft); color: var(--red); }
.status-badge.review, .status-badge.draft, .status-badge.retired { background: var(--surface-muted); color: var(--muted); }
.category-field { border: 1px solid var(--border); padding: 14px; margin: 0; }
.category-field legend { padding: 0 6px; font-weight: 700; }
.category-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px 12px; margin-bottom: 12px; }
.category-grid .check-option { align-items: flex-start; }
.policy-preview { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.policy-preview summary { cursor: pointer; font-weight: 700; }
.policy-preview pre { max-height: 440px; overflow: auto; white-space: pre-wrap; font: 14px/1.55 Georgia, serif; background: var(--surface-muted); padding: 16px; border: 1px solid var(--border); }
.tool-categories { color: var(--muted); font-size: 13px; font-weight: 600; }
.policy-form, .publish-form { display: grid; gap: 16px; }
.policy-form textarea[name="body_text"] { min-height: 620px; line-height: 1.55; }
.publish-form { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 18px; }
.publish-form .button { justify-self: start; }
.hash-cell { font-family: Consolas, "Courier New", monospace; font-size: 12px; }
.tool-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: end; }
.tool-form .button { justify-self: start; }
.tool-admin-list { display: grid; gap: 16px; }
.control-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.control-summary article { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--primary); padding: 20px; }
.control-summary article > span { display: block; color: var(--primary); font-size: 13px; font-weight: 800; margin-bottom: 8px; }
.control-summary h2 { font-size: 17px; }
.control-summary p { color: var(--muted); margin-bottom: 0; }
.boundary-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 26px; }
.boundary-grid p { border-top: 1px solid var(--border); padding: 14px 0; margin: 0; }
.align-left { justify-content: flex-start; margin-top: 12px; }

.policy-shell { max-width: 1040px; margin: 36px auto 70px; padding: 0 24px; }
.policy-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; border-bottom: 1px solid var(--border); padding-bottom: 24px; margin-bottom: 24px; }
.policy-heading > div > span { color: var(--primary); text-transform: uppercase; font-size: 12px; font-weight: 800; }
.policy-heading h1 { margin: 6px 0 8px; }
.policy-heading p { color: var(--muted); margin: 0; }
.policy-meta { min-width: 270px; margin: 0; }
.policy-meta > div { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid var(--border); padding: 7px 0; }
.policy-meta dt { color: var(--muted); }
.policy-meta dd { margin: 0; font-weight: 650; }
.policy-document { background: var(--surface); border: 1px solid var(--border); padding: 38px 44px; line-height: 1.7; }
.policy-document h2 { font-size: 19px; color: var(--primary-dark); margin: 28px 0 8px; border-top: 1px solid var(--border); padding-top: 24px; }
.policy-document h2:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.policy-document p { margin-bottom: 16px; }
.tool-catalog, .signature-section { margin-top: 42px; }
.catalog-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.catalog-item { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid var(--primary); padding: 19px; }
.catalog-item header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.catalog-item h3 { margin: 0; }
.catalog-item dl { margin: 16px 0 0; }
.catalog-item dl div { border-top: 1px solid var(--border); padding: 10px 0; }
.catalog-item dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.catalog-item dd { margin: 3px 0 0; }
.catalog-item > p { color: var(--muted); margin: 10px 0 0; font-size: 13px; }
.signature-section { background: var(--surface); border: 1px solid var(--border); padding: 30px; }
#policy-sign-form { display: grid; gap: 20px; }
.signature-field { display: grid; gap: 8px; }
.signature-label { display: flex; justify-content: space-between; align-items: center; font-weight: 650; }
#signature-canvas { width: 100%; height: 220px; display: block; border: 1px solid #9fb2aa; background: white; touch-action: none; cursor: crosshair; }
#signature-canvas.invalid { border: 2px solid var(--red); }
.signature-field p { color: var(--muted); font-size: 13px; margin: 0; }
.policy-complete { margin: 70px auto; width: min(100%, 760px); max-width: 760px; }
.evidence-list { margin: 28px 0 18px; text-align: left; }
.evidence-list div { border-top: 1px solid var(--border); padding: 10px 0; }
.evidence-list dt { color: var(--muted); font-size: 12px; font-weight: 700; }
.evidence-list dd { margin: 4px 0 0; font-family: Consolas, "Courier New", monospace; overflow-wrap: anywhere; font-size: 12px; }

@media (max-width: 1100px) {
  .filter-bar { grid-template-columns: repeat(3, 1fr); }
  .report-grid.three { grid-template-columns: 1fr 1fr; }
  .report-grid.three > :last-child { grid-column: 1 / -1; }
  .report-header { flex-wrap: wrap; }
  .report-header > div:first-child { flex: 1 1 auto; }
  .admin-tabs { order: 3; width: 100%; overflow-x: auto; }
}

@media (max-width: 720px) {
  body { font-size: 14px; }
  h1 { font-size: 25px; }
  .header-inner, .survey-shell { padding-left: 16px; padding-right: 16px; }
  .survey-shell { margin-top: 22px; }
  .survey-heading { align-items: flex-start; }
  .two-columns, .check-grid, .report-grid.three, .report-grid.two, .metric-strip, .filter-bar { grid-template-columns: 1fr; }
  .report-grid.three > :last-child { grid-column: auto; }
  .survey-step { padding: 22px 18px; }
  .form-actions { padding: 15px 18px; }
  .choice-row { flex-direction: column; }
  .radio-option { width: 100%; }
  .tool-entry { padding: 18px 14px; }
  .review-summary > div { grid-template-columns: 1fr; gap: 4px; }
  .report-header { position: static; padding: 12px 16px; display: grid; grid-template-columns: minmax(0, 1fr); align-items: flex-start; gap: 10px; }
  .report-header > * { min-width: 0; width: 100%; }
  .admin-tabs { order: initial; width: 100%; overflow-x: auto; }
  .header-actions { flex-wrap: wrap; justify-content: flex-start; }
  .report-shell { padding: 20px 14px; }
  .report-title { align-items: flex-start; flex-direction: column; }
  .report-nav { top: 0; }
  .admin-title { align-items: flex-start; flex-direction: column; }
  .question-form, .update-layout, .security-list { grid-template-columns: 1fr; }
  .tool-form, .control-summary, .boundary-grid, .catalog-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: 1fr; }
  .question-form .wide { grid-column: auto; }
  .report-actions { justify-content: flex-start; flex-wrap: wrap; }
  .header-inner { align-items: flex-start; flex-direction: column; }
  .public-nav { width: 100%; overflow-x: auto; }
  .policy-shell { padding: 0 14px; margin-top: 22px; }
  .policy-heading { align-items: flex-start; flex-direction: column; }
  .policy-meta { width: 100%; min-width: 0; }
  .policy-document { padding: 24px 19px; }
  .signature-section { padding: 22px 18px; }
  #signature-canvas { height: 180px; }
}

@media print {
  :root, body { background: white; }
  .report-header, .filter-bar, .report-nav { display: none !important; }
  .report-shell { max-width: none; padding: 0; }
  .report-grid.three, .report-grid.two, .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .chart-panel, .metric-strip > div, .table-wrap { break-inside: avoid; box-shadow: none; }
  .report-section { break-before: auto; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}
