/* ============ 设计令牌 ============ */
:root {
  --ink: #16211d;
  --ink-2: #4c5c56;
  --ink-3: #8a968f;
  --bg: #f4f3ee;
  --surface: #ffffff;
  --line: #e5e2d8;
  --line-soft: #efedE5;
  --primary: #17624f;
  --primary-deep: #0f4638;
  --primary-soft: #eaf3ef;
  --accent: #c4762a;
  --accent-soft: #fbf0e2;
  --danger: #b4462f;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(22, 33, 29, 0.05);
  --shadow: 0 2px 8px rgba(22, 33, 29, 0.06), 0 12px 32px -12px rgba(22, 33, 29, 0.12);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", system-ui, sans-serif;
  --mono: "SF Mono", "Cascadia Mono", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(900px 420px at 50% -10%, #fbfaf6 0%, rgba(251, 250, 246, 0) 70%),
    var(--bg);
  line-height: 1.65;
  font-size: 15px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--primary); }

/* ============ 品牌页头 ============ */
.masthead {
  max-width: 600px;
  margin: 0 auto;
  padding: 28px 20px 0;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0;
  box-shadow: 0 2px 6px rgba(23, 98, 79, 0.25);
}
.brand-text { line-height: 1.25; }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: 0.02em; }
.brand-sub { font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.04em; }

.eyebrow {
  font-size: 11.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin: 0 0 8px;
}
h1.page-title {
  font-size: 24px;
  line-height: 1.35;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
  font-weight: 650;
}
.page-sub {
  margin: 0;
  color: var(--ink-2);
  font-size: 13.5px;
}
.intro {
  margin: 14px 0 0;
  padding: 12px 14px;
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.6;
}

.masthead.compact { padding-top: 16px; }
.masthead.compact .eyebrow,
.masthead.compact .page-title,
.masthead.compact .page-sub,
.masthead.compact .intro { display: none; }
.masthead.compact .brand { margin-bottom: 0; }

/* ============ 进度条 ============ */
.progress-wrap {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(244, 243, 238, 0.92);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
  margin-top: 20px;
}
.progress-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 10px 20px 11px;
}
.progress-track {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.progress-seg {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: #e2dfd4;
  overflow: hidden;
  position: relative;
}
.progress-seg::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 0;
  background: var(--primary);
  border-radius: 99px;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.progress-seg.done::after { width: 100%; }
.progress-seg.active::after { width: 100%; background: var(--accent); }
.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.02em;
}
.progress-meta strong { color: var(--ink); font-weight: 600; }

/* ============ 表单主体 ============ */
.shell {
  max-width: 600px;
  margin: 0 auto;
  padding: 22px 20px 140px;
}
.section-head { margin-bottom: 18px; }
.section-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 3px 9px;
  border-radius: 99px;
  letter-spacing: 0.04em;
  margin-bottom: 9px;
}
.section-title {
  font-size: 19px;
  margin: 0 0 4px;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.section-desc { margin: 0; font-size: 12.5px; color: var(--ink-3); }

.qcard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 16px 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.qcard.answered { border-color: #cfe1d9; }
.qcard.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(180, 70, 47, 0.1);
  animation: shake 0.35s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.q-head { display: flex; gap: 9px; align-items: flex-start; margin-bottom: 13px; }
.q-num {
  flex: none;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  background: #f4f3ee;
  border-radius: 6px;
  padding: 2px 6px;
  margin-top: 2px;
  letter-spacing: 0.02em;
}
.q-title { font-size: 14.5px; font-weight: 550; line-height: 1.55; margin: 0; }
.q-req { color: var(--accent); margin-left: 2px; font-size: 13px; }
.q-hint {
  font-size: 11.5px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 99px;
  padding: 1px 8px;
  margin-left: 6px;
  white-space: nowrap;
  font-weight: 500;
  display: inline-block;
  vertical-align: 1px;
}

/* 选项 */
.opts { display: flex; flex-direction: column; gap: 8px; }
.opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fdfdfb;
  transition: all 0.16s ease;
  position: relative;
  cursor: pointer;
  min-height: 46px;
  font-size: 14px;
}
.opt:hover { border-color: #cfd8d3; background: #fff; }
.opt:active { transform: scale(0.993); }
.opt input { position: absolute; opacity: 0; pointer-events: none; }
.mark {
  flex: none;
  width: 19px; height: 19px;
  border: 1.6px solid #c8cec9;
  background: #fff;
  display: grid;
  place-items: center;
  transition: all 0.16s ease;
}
.opt[data-shape="radio"] .mark { border-radius: 50%; }
.opt[data-shape="check"] .mark { border-radius: 6px; }
.mark::after {
  content: "";
  opacity: 0;
  transform: scale(0.4);
  transition: all 0.16s ease;
}
.opt[data-shape="radio"] .mark::after {
  width: 9px; height: 9px; border-radius: 50%; background: #fff;
}
.opt[data-shape="check"] .mark::after {
  width: 10px; height: 6px;
  border-left: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(-45deg) scale(0.5);
  margin-top: -2px;
}
.opt.selected {
  border-color: var(--primary);
  background: var(--primary-soft);
  box-shadow: 0 0 0 1px var(--primary) inset;
}
.opt.selected .mark { background: var(--primary); border-color: var(--primary); }
.opt.selected .mark::after { opacity: 1; transform: scale(1); }
.opt[data-shape="check"].selected .mark::after { transform: rotate(-45deg) scale(1); }
.opt.selected .opt-label { color: var(--primary-deep); font-weight: 550; }
.opt.disabled { opacity: 0.42; }

/* 其他填空 */
.other-input {
  margin-left: 29px;
  margin-top: 8px;
  width: calc(100% - 29px);
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fdfdfb;
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.16s;
}
.other-input:focus { border-color: var(--primary); background: #fff; }

/* 量表 */
.scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.scale-btn {
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fdfdfb;
  text-align: center;
  transition: all 0.16s ease;
  height: 54px;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink-2);
}
.scale-btn:hover { border-color: #cfd8d3; background: #fff; color: var(--primary); }
.scale-btn:active { transform: scale(0.97); }
.scale-btn.selected {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
  box-shadow: 0 3px 12px -3px rgba(23, 98, 79, 0.55);
}
.scale-anchors {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  font-size: 11px;
  color: var(--ink-3);
  padding: 0 2px;
}

/* 文本题 */
.field {
  width: 100%;
  min-height: 84px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fdfdfb;
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.16s, background 0.16s;
}
.field:focus { border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px rgba(23, 98, 79, 0.08); }
.field::placeholder { color: #b6bdb8; }
.counter { text-align: right; font-size: 11px; color: var(--ink-3); margin-top: 4px; font-family: var(--mono); }

/* 底部操作栏 */
.actionbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
}
.actionbar-inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: center;
}
.btn {
  border-radius: 11px;
  padding: 13px 20px;
  font-size: 14.5px;
  font-weight: 600;
  transition: all 0.16s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  letter-spacing: 0.01em;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  flex: 1;
  box-shadow: 0 4px 14px -4px rgba(23, 98, 79, 0.5);
}
.btn-primary:hover { background: var(--primary-deep); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost {
  background: #fff;
  color: var(--ink-2);
  border: 1px solid var(--line);
  flex: none;
}
.btn-ghost:hover { border-color: #c9d2cd; color: var(--ink); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-accent { background: var(--accent); color: #fff; }

/* 校验提示 */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translate(-50%, 12px);
  background: #2b241f;
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: 99px;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 90;
  max-width: 86vw;
  text-align: center;
  box-shadow: 0 8px 24px -6px rgba(0, 0, 0, 0.35);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ============ 完成页 ============ */
.done-view {
  max-width: 600px;
  margin: 0 auto;
  padding: 56px 24px 80px;
  text-align: center;
}
.done-icon {
  width: 62px; height: 62px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  margin: 0 auto 20px;
  font-size: 28px;
  border: 2px solid #cfe1d9;
}
.done-view h2 { font-size: 21px; margin: 0 0 8px; font-weight: 650; }
.done-view p { color: var(--ink-2); font-size: 13.5px; margin: 0 auto 22px; max-width: 380px; }
.receipt {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.receipt-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  padding: 7px 0;
  border-bottom: 1px dashed var(--line-soft);
}
.receipt-row:last-child { border: none; }
.receipt-row span { color: var(--ink-3); }
.receipt-row strong { font-family: var(--mono); font-size: 12.5px; font-weight: 600; letter-spacing: 0.02em; }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 8px; }
.done-note {
  margin-top: 34px;
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.7;
}

/* ============ 管理后台 ============ */
.admin-body { background: #f2f1ec; }
.admin-shell { max-width: 1180px; margin: 0 auto; padding: 26px 24px 90px; }
.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.admin-head h1 { font-size: 22px; margin: 0 0 4px; font-weight: 650; letter-spacing: -0.01em; }
.admin-head p { margin: 0; font-size: 12.5px; color: var(--ink-3); }
.admin-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.tool-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 9px;
  padding: 8px 13px;
  font-size: 12.5px;
  font-weight: 550;
  color: var(--ink-2);
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.tool-btn:hover { border-color: var(--primary); color: var(--primary); }
.tool-btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.tool-btn.primary:hover { background: var(--primary-deep); }
.tool-btn.danger:hover { border-color: var(--danger); color: var(--danger); }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}
.kpi {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 15px 16px;
  box-shadow: var(--shadow-sm);
}
.kpi-label { font-size: 11.5px; color: var(--ink-3); letter-spacing: 0.03em; margin-bottom: 6px; }
.kpi-value { font-size: 26px; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-value small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 3px; }
.kpi-foot { font-size: 11px; color: var(--ink-3); margin-top: 5px; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 15px;
  margin-bottom: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.panel-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
}
.panel-head h3 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.panel-head .ph-sub { font-size: 11.5px; color: var(--ink-3); }
.panel-body { padding: 16px 18px; }
.panel-body.flush { padding: 0; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

/* 统计表 */
table.stat {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
table.stat th {
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.04em;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
table.stat td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line-soft);
  font-variant-numeric: tabular-nums;
  word-break: keep-all;
}
table.stat td:first-child { white-space: nowrap; }
table.stat tr:last-child td { border-bottom: none; }
table.stat td.num { text-align: right; font-family: var(--mono); font-size: 12px; white-space: nowrap; }
table.stat tr:hover td { background: #fbfaf6; }
.mini-bar {
  height: 5px;
  background: var(--primary);
  border-radius: 99px;
  min-width: 2px;
  opacity: 0.75;
}
.bar-cell { width: 84px; min-width: 84px; padding-right: 4px !important; }

/* 图表 */
.chart { margin: 4px 0 2px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart-legend { display: flex; gap: 14px; font-size: 11px; color: var(--ink-3); margin-top: 8px; flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 26px; height: 5px; border-radius: 99px; margin-right: 5px; vertical-align: 2px; }
.chart-foot {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
  letter-spacing: 0.01em;
}

/* 明细表 */
.table-scroll { max-height: 460px; overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th {
  position: sticky; top: 0;
  background: #faf9f5;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.03em;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  z-index: 1;
}
table.data td { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap; }
table.data tr.invalid td { color: var(--ink-3); text-decoration: line-through; background: #fbf6f4; }
table.data tr:hover td { background: #fbfaf6; }
.pill {
  display: inline-block;
  font-size: 10.5px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 550;
}
.pill.muted { background: #f1f0ea; color: var(--ink-3); }
.icon-btn {
  font-size: 11px;
  color: var(--ink-3);
  padding: 2px 6px;
  border-radius: 5px;
  border: 1px solid transparent;
}
.icon-btn:hover { border-color: var(--line); color: var(--ink); background: #fff; }
.icon-btn.danger:hover { color: var(--danger); border-color: #edd6d0; }

.st-title {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-2);
  letter-spacing: 0.03em;
  padding: 0 10px 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

/* 横向堆叠条 */
.sbar-row {
  display: grid;
  grid-template-columns: 168px 1fr 48px;
  align-items: center;
  gap: 12px;
  padding: 7px 0;
}
.sbar-label { font-size: 12.5px; color: var(--ink-2); }
.sbar {
  display: flex;
  height: 26px;
  border-radius: 7px;
  overflow: hidden;
  background: #f1f0ea;
  gap: 1.5px;
}
.sbar span {
  display: grid;
  place-items: center;
  font-size: 10.5px;
  color: rgba(255, 255, 255, 0.92);
  font-family: var(--mono);
  transition: flex-basis 0.4s ease;
}
.sbar-mean {
  text-align: right;
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}

.empty {
  text-align: center;
  padding: 46px 20px;
  color: var(--ink-3);
  font-size: 13px;
}
.empty b { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 5px; font-weight: 600; }

.note {
  font-size: 11.5px;
  color: var(--ink-3);
  line-height: 1.7;
  padding: 12px 16px;
  background: #faf9f5;
  border-top: 1px solid var(--line-soft);
}

.hidden { display: none !important; }

/* 抽屉/弹层 */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(22, 33, 29, 0.42);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff;
  border-radius: 16px;
  max-width: 460px;
  width: 100%;
  padding: 22px;
  box-shadow: 0 24px 60px -16px rgba(0, 0, 0, 0.3);
  max-height: 86vh;
  overflow: auto;
}
.modal h3 { margin: 0 0 8px; font-size: 16px; font-weight: 650; }
.modal p { font-size: 13px; color: var(--ink-2); margin: 0 0 16px; line-height: 1.65; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; }

@media (max-width: 560px) {
  .admin-shell { padding: 18px 14px 90px; }
  .panel-body { padding: 13px 14px; }
  .kpi-value { font-size: 22px; }
  h1.page-title { font-size: 21px; }

}
