/* 河北省医院紧急输血基线调查 · 填写页
   纸质调查表的样子：浅灰底上一张白色表单，题目之间靠留白分开，不用细线分隔；
   部分标题用浅色色块，深红只用于少量点缀（输血主题）。 */

:root {
  --ink: #1c1c1c;
  --text: #2b2b2b;
  --muted: #646464;
  --quiet: #8a8a8a;
  --line: #cfcfcf;
  --line-soft: #e8e8e8;
  --accent: #8e1b1b;
  --error: #b42318;
  --error-line: #d9534f;
  --checked: #f3f3f3;
  --page: #efefed;
  --band: #f3efee;
  --panel-line: #dcdcdc;
  /* 兼容旧样式变量名 */
  --slate-50: #fafafa;
  --slate-300: #cfcfcf;
  --slate-500: #8a8a8a;
  --slate-600: #646464;
  --slate-700: #444;
  --slate-800: #2b2b2b;
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, -apple-system, sans-serif;
  color: var(--text);
  background: var(--page);
}

*, *::before, *::after { box-sizing: border-box; }
html { min-width: 320px; -webkit-text-size-adjust: 100%; }
body { position: relative; margin: 0; background: var(--page); line-height: 1.6; }
/* 整页背景：回龙观院区国家紧急医学救援基地实景，大幅淡化，不影响阅读 */
body::before { content: ""; position: fixed; inset: 0; z-index: -1; background: url("bg-rescue-base.jpg") center 35% / cover no-repeat; filter: grayscale(0.5); opacity: 0.12; pointer-events: none; }
[hidden] { display: none !important; }
a { color: var(--ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

/* ---------- 页头 ---------- */
/* 页头：同一张照片做横幅，左侧白色渐隐压字，右侧露出“国家紧急医学救援基地”楼体 */
.masthead {
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.97) 0%, rgba(255, 255, 255, 0.92) 40%, rgba(255, 255, 255, 0.45) 70%, rgba(255, 255, 255, 0.2) 100%),
    url("bg-rescue-base.jpg") right 24% / cover no-repeat; }
.masthead-inner { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 30px 0 26px; }
.masthead-org { margin: 0; color: var(--muted); font-size: 13px; letter-spacing: 0.02em; }
.masthead-org span { white-space: nowrap; }
.masthead h1 { margin: 4px 0 2px; color: var(--ink); font-size: 24px; font-weight: 600; letter-spacing: 0.02em; }
.masthead-sub { margin: 0; color: var(--muted); font-size: 14px; }
.save-state { margin-left: 16px; color: var(--quiet); font-size: 13px; }

/* ---------- 版面 ---------- */
.app-shell { width: min(1080px, calc(100% - 32px)); margin: 20px auto 32px; display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 40px; align-items: start; }
.progress-panel { position: sticky; top: 16px; padding: 14px 16px; border: 1px solid var(--panel-line); background: #fff; font-size: 14px; }
.progress-header { display: flex; justify-content: space-between; color: var(--muted); }
#progressLabel { color: var(--ink); }
.progress-track { height: 8px; margin: 8px 0 12px; background: #e6e6e6; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--accent); transition: width 0.2s; }
.step-nav { display: grid; gap: 2px; }
.step-nav button { padding: 5px 0; border: 0; background: none; color: var(--muted); text-align: left; font-size: 14px; line-height: 1.5; }
.step-nav button.complete { color: var(--text); }
.step-nav button.active { color: var(--ink); font-weight: 600; }
.step-nav button:disabled { color: #b5b5b5; cursor: default; }
.step-nav button:not(:disabled):hover { text-decoration: underline; }

.form-workspace { min-width: 0; padding: 26px 32px 28px; border: 1px solid var(--panel-line); background: #fff; }
.notice { margin: 0 0 14px; color: var(--error); font-size: 14px; }
.preview-banner { margin: 0 0 14px; padding: 8px 12px; border: 1px dashed var(--line); color: var(--muted); font-size: 14px; }

/* ---------- 每一部分的标题与简介 ---------- */
.stage-header { margin: 0 0 6px; padding: 12px 16px; background: var(--band); }
.stage-header h2 { margin: 0; color: var(--accent); font-size: 19px; font-weight: 600; }
.stage-desc { margin: 6px 0 0; color: var(--muted); font-size: 14px; }
.project-intro-section { margin-bottom: 24px; }
.project-intro-title { margin: 0 0 6px; color: var(--ink); font-size: 16px; font-weight: 600; }
.survey-intro { margin: 0; text-indent: 2em; font-size: 15px; line-height: 1.8; }
.survey-definition { margin: 10px 0 0; color: var(--ink); font-size: 15px; font-weight: 600; }
.survey-guide { margin: 6px 0 0; color: var(--muted); font-size: 14px; }

/* 紧急用血流程示意：编号方框 + 箭头，像科室墙上的流程图 */
.flow-figure { margin: 16px 0 0; }
.flow-figure figcaption { margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.flow { display: flex; align-items: stretch; margin: 0; padding: 0; list-style: none; }
.flow li { position: relative; display: flex; flex: 1 1 0; align-items: center; justify-content: center; gap: 6px; margin-right: 22px; padding: 8px 6px; border: 1px solid #d6cfcd; background: var(--band); font-size: 13px; color: var(--ink); text-align: center; line-height: 1.4; }
.flow li:last-child { margin-right: 0; }
.flow li::after { content: "→"; position: absolute; top: 50%; right: -18px; margin-top: -0.75em; color: var(--accent); font-size: 14px; line-height: 1.5; }
.flow li:last-child::after { display: none; }
.flow li b { flex: 0 0 auto; color: var(--accent); font-weight: 600; }

/* ---------- 题目 ---------- */
.question-list { }
.question { padding: 14px 0 12px; }
.question-label { display: flex; gap: 10px; align-items: baseline; color: var(--ink); font-size: 15px; font-weight: 500; line-height: 1.6; text-wrap: pretty; }
label.question-label { display: block; }
.question-code { flex: 0 0 auto; min-width: 2.6em; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; font-weight: 400; }
.required-star, .star { margin-left: 3px; color: var(--accent); }
.label-tail { white-space: nowrap; }
.question-label .kw { color: var(--accent); font-weight: 600; }
.question-helper { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.6; text-wrap: pretty; }
.question > .options, .question > .ranking-list, .question > .numtable, .question > .number-wrap,
.question > .text-input, .question > .textarea-input, .question > .select-input, .question > .basic-custom-wrap { margin-top: 10px; }
.question .question-code ~ span { flex: 1 1 auto; }

.options { display: grid; gap: 2px; }
.options.inline { display: flex; flex-wrap: wrap; gap: 4px 22px; }
.option { display: flex; align-items: flex-start; gap: 9px; padding: 5px 6px; margin: 0 -6px; border-radius: 2px; font-size: 15px; line-height: 1.55; cursor: pointer; }
.option:hover { background: #fafafa; }
.option:has(input:checked) { background: var(--checked); }
.option input { flex: 0 0 auto; width: 16px; height: 16px; margin: 3px 0 0; accent-color: var(--accent); }
.option-group { margin: 10px 0 2px; color: var(--muted); font-size: 13px; }
.option-group:first-child { margin-top: 0; }

.text-input, .select-input, .textarea-input, .detail-input {
  width: 100%; max-width: 560px; min-height: 38px; padding: 7px 10px;
  border: 1px solid #bdbdbd; border-radius: 2px; background: #fff; color: var(--ink); font-size: 15px;
}
.textarea-input { max-width: none; min-height: 96px; line-height: 1.6; resize: vertical; }
.text-input:focus, .select-input:focus, .textarea-input:focus, .detail-input:focus { outline: 2px solid #9a9a9a; outline-offset: 0; border-color: #9a9a9a; }
.text-input[readonly] { background: #f6f6f6; color: var(--muted); }
.select-input:disabled { background: #f6f6f6; color: var(--muted); }

.detail-wrap { margin: 2px 0 8px 31px; }
.detail-label { display: block; margin-bottom: 3px; color: var(--muted); font-size: 13px; }
.detail-input { max-width: 420px; min-height: 34px; font-size: 14px; }
.basic-custom-wrap { margin-left: 0; }

.ranking-list { display: grid; gap: 8px; max-width: 560px; }
.ranking-row { display: grid; grid-template-columns: 64px minmax(0, 1fr); align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }

.number-wrap { display: flex; align-items: center; gap: 8px; max-width: 240px; }
.number-unit { color: var(--muted); font-size: 14px; white-space: nowrap; }
.number-unknown { display: inline-flex; margin-top: 8px; }
.numtable { display: grid; gap: 8px; max-width: 720px; }
.numtable-row { display: grid; grid-template-columns: minmax(0, 1fr) 150px; gap: 6px 12px; align-items: center; }
.numtable-row:has(.numtable-name) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 150px; }
.numtable-label { font-size: 14px; }
.numtable-input { display: flex; align-items: center; gap: 6px; }

/* 报错：红字 + 输入框红边，不加底色和竖条 */
.field-error { margin: 6px 0 0; color: var(--error); font-size: 13px; }
.question.has-error .text-input, .question.has-error .select-input, .question.has-error .textarea-input, .question.has-error .detail-input { border-color: var(--error-line); }

/* ---------- 底部按钮 ---------- */
.form-actions { display: flex; align-items: center; gap: 12px; margin-top: 18px; padding: 16px; background: #f6f6f6; }
.required-note { margin-left: auto; color: var(--muted); font-size: 13px; }
.button { min-height: 38px; padding: 7px 20px; border: 1px solid var(--line); border-radius: 2px; background: #fff; color: var(--ink); font-size: 15px; }
.button:hover { border-color: #8a8a8a; }
.button.primary { border-color: var(--ink); background: var(--ink); color: #fff; }
.button.primary:hover { background: #000; }
.button:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- 核对页 ---------- */
.review-groups { margin-top: 6px; }
.review-group { padding: 10px 0 12px; }
.review-group h3 { margin: 0 0 6px; padding: 6px 12px; background: #f4f4f4; color: var(--ink); font-size: 15px; font-weight: 600; }
.review-group dl { padding: 0 12px; }
.review-group dl { margin-top: 0; margin-bottom: 0; }
.review-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; padding: 5px 0; font-size: 14px; }
.review-row dt { color: var(--muted); }
.review-row dd { margin: 0; color: var(--ink); font-weight: 500; overflow-wrap: anywhere; }

.fatal-error { padding: 40px 0; }
.fatal-error h2 { margin: 0 0 6px; font-size: 18px; }

/* ---------- 页脚 ---------- */
.site-footer { background: #e4e4e2; }
.footer-inner { width: min(1080px, calc(100% - 32px)); margin: 0 auto; padding: 16px 0 28px; display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; color: var(--muted); font-size: 13px; }
.footer-text p { margin: 0 0 4px; }
.footer-line span { margin-right: 16px; }
.footer-line span:first-child:last-child, .footer-line span:last-child { margin-right: 0; }
.footer-note { color: var(--quiet); }
.photo-credit { color: var(--quiet); }
.admin-entry { flex: 0 0 auto; color: var(--quiet); }

/* ---------- 提交成功 ---------- */
.success-dialog { width: min(420px, calc(100% - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 2px; color: var(--text); }
.success-dialog::backdrop { background: rgba(0, 0, 0, 0.3); }
.success-dialog h2 { margin: 0 0 8px; color: var(--ink); font-size: 18px; font-weight: 600; }
.success-dialog p { margin: 0 0 18px; font-size: 15px; }
.dialog-actions { display: flex; justify-content: flex-end; }

/* ---------- 手机 ---------- */
@media (max-width: 760px) {
  .masthead-inner, .app-shell, .footer-inner { width: calc(100% - 28px); }
  .masthead h1 { font-size: 20px; }
  .masthead { background: linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.72)), url("bg-rescue-base.jpg") center 22% / cover no-repeat; }
  .save-state { display: block; margin: 2px 0 0; }
  .app-shell { width: calc(100% - 20px); grid-template-columns: 1fr; gap: 10px; margin-top: 10px; margin-bottom: 20px; }
  .progress-panel { position: static; padding: 10px 14px; }
  .form-workspace { padding: 18px 16px 20px; }
  .stage-header { margin-left: -16px; margin-right: -16px; padding: 10px 16px; }
  .progress-track { margin-bottom: 0; }
  .step-nav { display: none; }
  .flow { flex-wrap: wrap; row-gap: 8px; }
  .flow li { flex: 0 0 auto; margin-right: 20px; padding: 5px 8px; font-size: 13px; }
  .flow li::after { right: -16px; }
  .options.inline { display: grid; gap: 2px; }
  /* 题号不再单占一列，和题干排在同一段里，题干可用整行宽度 */
  .question-label { display: block; font-size: 16px; }
  .question-code { display: inline; min-width: 0; margin-right: 6px; font-size: 13px; }
  .option { font-size: 16px; padding: 7px 6px; }
  .option input { width: 18px; height: 18px; margin-top: 3px; }
  .stage-header h2 { font-size: 18px; }
  .stage-desc { font-size: 13px; }
  .review-row { grid-template-columns: 1fr; gap: 2px; }
  .numtable-row, .numtable-row:has(.numtable-name) { grid-template-columns: 1fr; gap: 4px; }
  .detail-wrap { margin-left: 25px; }
  .form-actions { flex-wrap: wrap; gap: 10px; margin: 10px -16px -20px; padding: 14px 16px; }
  .form-actions .button { flex: 1 1 0; min-height: 46px; font-size: 16px; }
  .required-note { order: 3; width: 100%; margin: 2px 0 0; text-align: center; }
  .footer-inner { flex-direction: column; gap: 10px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); line-height: 1.7; }
  .footer-text p { margin-bottom: 8px; }
  .footer-line span { display: block; margin-right: 0; }
  .footer-line span:first-child:not(:last-child) { color: var(--text); }
}

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

@media print {
  .progress-panel, .form-actions, .site-footer, .save-state { display: none; }
  .app-shell { display: block; }
}
