:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --border: #e3e8f0;
  --text: #1f2937;
  --text-muted: #64748b;
  --text-faint: #94a3b8;
  --primary: #2f6fed;
  --primary-dark: #2158c9;
  --primary-soft: #eaf1ff;
  --green: #15803d;
  --green-soft: #e8f6ec;
  --yellow: #b45309;
  --yellow-soft: #fdf3e1;
  --red: #b91c1c;
  --red-soft: #fdeaea;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(31, 41, 55, 0.06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

button, input { font: inherit; }

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 920px;
  margin: 0 auto;
  padding: 0 20px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 4px 18px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  display: grid; place-items: center;
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 12px; background: var(--primary); color: #fff;
  font-size: 22px; line-height: 1;
}
.brand-title { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.brand-sub { font-size: 11px; color: var(--text-faint); letter-spacing: .6px; }

.header-nav { display: flex; gap: 8px; flex-wrap: wrap; }
.nav-btn {
  border: 1px solid transparent; background: transparent; color: var(--text-muted);
  padding: 7px 14px; border-radius: 9px; cursor: pointer; font-size: 14px;
}
.nav-btn:hover { background: #e9edf5; color: var(--text); }
.nav-btn.active { background: var(--primary-soft); color: var(--primary-dark); font-weight: 600; }

.app-main { flex: 1; padding: 6px 0 30px; min-width: 0; }

.app-footer {
  border-top: 1px solid var(--border); padding: 18px 4px 26px;
  color: var(--text-faint); font-size: 12px;
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px;
  min-width: 0;
}
.card + .card { margin-top: 18px; }

.page-title { font-size: 24px; font-weight: 700; margin: 0 0 8px; }
.page-lead { color: var(--text-muted); margin: 0 0 22px; }

.chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 18px 0 22px; }
.chip {
  background: var(--surface-soft); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; font-size: 13px; color: var(--text-muted);
}
.chip strong { color: var(--text); }

.notice { border-radius: 12px; padding: 16px 18px; font-size: 13.5px; line-height: 1.75; }
.notice-title { font-weight: 700; margin-bottom: 6px; display: flex; align-items: center; gap: 7px; }
.notice p { margin: 0 0 8px; }
.notice p:last-child { margin-bottom: 0; }
.notice-neutral { background: var(--surface-soft); border: 1px solid var(--border); color: var(--text-muted); }
.notice-info { background: var(--primary-soft); border: 1px solid #cbdcff; color: #274c8f; }
.notice-warn { background: var(--red-soft); border: 1px solid #f5cccc; color: #7f1d1d; }

.actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 24px; }
.btn {
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 10px 20px; border-radius: 10px; cursor: pointer; font-weight: 600;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover:not(:disabled) { background: var(--surface-soft); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dark); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-muted); }
.btn-danger { color: var(--red); border-color: #f2cccc; }
.btn-danger:hover:not(:disabled) { background: var(--red-soft); }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }

.consent-row {
  display: flex; align-items: flex-start; gap: 10px; margin-top: 20px;
  padding: 14px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface-soft); cursor: pointer; font-size: 13.5px;
}
.consent-row input { margin-top: 4px; accent-color: var(--primary); width: 18px; height: 18px; flex: 0 0 18px; }

/* ---------- progress ---------- */
.progress-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.progress-head strong { font-size: 15px; }
.progress-head span { color: var(--text-muted); font-size: 13px; }
.progress-track { height: 8px; background: #e8edf5; border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 999px; transition: width .25s ease; }

.q-meta { display: flex; align-items: center; gap: 10px; margin: 24px 0 6px; flex-wrap: wrap; }
.q-index { font-size: 13px; color: var(--text-faint); }
.tag {
  display: inline-block; background: var(--primary-soft); color: var(--primary-dark);
  border-radius: 6px; padding: 2px 9px; font-size: 12px; font-weight: 600;
}
.q-text { font-size: 19px; font-weight: 600; line-height: 1.6; margin: 4px 0 22px; }

.auto-hint {
  font-size: 12px; color: var(--primary-dark); background: var(--primary-soft);
  border-radius: 8px; padding: 7px 12px; margin-bottom: 14px; display: inline-block;
}

.options { display: grid; gap: 9px; }
.option {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border); border-radius: 10px;
  padding: 12px 15px; min-height: 52px;
  cursor: pointer; background: var(--surface);
  transition: border-color .15s, background .15s;
}
.option:hover { border-color: #b8c9ee; background: var(--surface-soft); }
.option.selected { border-color: var(--primary); background: var(--primary-soft); }
.option-radio {
  width: 20px; height: 20px; flex: 0 0 20px;
  border: 2px solid #cbd5e1; border-radius: 50%; display: grid; place-items: center;
}
.option.selected .option-radio { border-color: var(--primary); }
.option.selected .option-radio::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--primary);
}
.option-label { font-size: 15px; }

.navigator { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 18px; }
.navigator-title { font-size: 12px; color: var(--text-faint); margin-bottom: 10px; }
.nav-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; }
.nav-dot {
  aspect-ratio: 1; min-height: 34px;
  border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); color: var(--text-faint);
  font-size: 11px; cursor: pointer; display: grid; place-items: center; padding: 0;
}
.nav-dot.answered { background: var(--primary-soft); border-color: #bcd0f5; color: var(--primary-dark); font-weight: 700; }
.nav-dot.current { outline: 2px solid var(--primary); outline-offset: 1px; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); color: var(--text);
}
.field input:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field-hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }
.field-error { color: var(--red); font-size: 12px; margin-top: 5px; min-height: 18px; }

/* ---------- result: red / yellow / green ---------- */
.status-banner {
  display: flex; align-items: center; gap: 20px;
  border: 1px solid; border-radius: 12px; padding: 22px 24px;
}
.status-banner.tone-green { background: var(--green-soft); border-color: #b7e0c4; }
.status-banner.tone-yellow { background: var(--yellow-soft); border-color: #f0d9a8; }
.status-banner.tone-red { background: var(--red-soft); border-color: #f3c2c2; }

.banner-score {
  flex: 0 0 96px; width: 96px; text-align: center;
  border-right: 1px solid rgba(0,0,0,.08); padding-right: 16px;
}
.banner-score strong {
  display: block; font-size: 46px; line-height: 1; font-weight: 800;
  color: var(--banner-color); font-variant-numeric: tabular-nums;
}
.banner-score span { display: block; font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.banner-main { min-width: 0; }
.banner-label { font-size: 20px; font-weight: 700; color: var(--banner-color); margin-bottom: 6px; }
.banner-summary { font-size: 14px; line-height: 1.65; }
.banner-meta { font-size: 11px; color: var(--text-faint); margin-top: 10px; }

.scale-legend { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; color: var(--text-muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-item i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.legend-green i { background: var(--green); }
.legend-yellow i { background: var(--yellow); }
.legend-red i { background: var(--red); }

.level-badge { display: inline-block; border-radius: 999px; padding: 4px 14px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.tone-green { color: var(--green); background: var(--green-soft); }
.tone-yellow { color: var(--yellow); background: var(--yellow-soft); }
.tone-red { color: var(--red); background: var(--red-soft); }

.section-title { font-size: 16px; font-weight: 700; margin: 0 0 14px; padding-left: 10px; border-left: 3px solid var(--primary); }
.dim-row { margin-bottom: 16px; }
.dim-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.dim-name { font-weight: 600; font-size: 14px; display: inline-flex; align-items: center; gap: 7px; }
.dim-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: 0 0 9px; }
.dim-score { font-size: 13px; font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.dim-track { height: 8px; background: #e8edf5; border-radius: 999px; overflow: hidden; }
.dim-fill { height: 100%; border-radius: 999px; }
.dim-feedback { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; }

.list { margin: 0; padding-left: 20px; }
.list li { margin-bottom: 8px; }
.resource-item { display: flex; gap: 10px; padding: 10px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; flex-wrap: wrap; }
.resource-item:last-child { border-bottom: none; }
.resource-name { font-weight: 600; min-width: 130px; }
.resource-usage { color: var(--text-muted); }

.record-item {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--border); border-left-width: 5px;
  border-radius: 11px; padding: 14px 16px; margin-bottom: 10px; background: var(--surface-soft);
}
.record-item.tone-green { border-left-color: var(--green); background: var(--green-soft); }
.record-item.tone-yellow { border-left-color: var(--yellow); background: var(--yellow-soft); }
.record-item.tone-red { border-left-color: var(--red); background: var(--red-soft); }
.record-main { flex: 1 1 180px; min-width: 0; }
.record-date { font-weight: 600; }
.record-meta { font-size: 12px; color: var(--text-muted); }
.record-score { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }

.answer-review { border-top: 1px solid var(--border); padding-top: 8px; }
.answer-item { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 13.5px; }
.answer-item:last-child { border-bottom: none; }
.answer-no { color: var(--text-faint); min-width: 30px; font-variant-numeric: tabular-nums; }
.answer-text { flex: 1; min-width: 0; }
.answer-value { color: var(--primary-dark); font-weight: 600; min-width: 70px; text-align: right; }

.empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.empty-icon { font-size: 36px; color: var(--text-faint); margin-bottom: 8px; }
.toast-root { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: max-content; max-width: 90vw; }
.toast { background: #1f2937; color: #fff; padding: 10px 18px; border-radius: 9px; font-size: 13.5px; box-shadow: 0 8px 24px rgba(0,0,0,.18); }
.toast.error { background: var(--red); }

.loading { text-align: center; padding: 70px 20px; color: var(--text-muted); }
.spinner {
  width: 28px; height: 28px; margin: 0 auto 12px;
  border: 3px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .app-shell { padding: 0 12px; }
  .app-header { padding: 16px 2px 12px; gap: 10px; }
  .brand-title { font-size: 17px; }
  .brand-sub { font-size: 10px; }
  .card { padding: 20px 16px; border-radius: 12px; }
  .page-title { font-size: 21px; }
  .page-lead { font-size: 14px; margin-bottom: 16px; }
  .q-text { font-size: 17px; margin-bottom: 16px; }
  .option { min-height: 54px; padding: 12px; }
  .option-label { font-size: 15px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .nav-grid { grid-template-columns: repeat(8, 1fr); }
  .nav-dot { min-height: 38px; }
  .status-banner { padding: 18px 16px; gap: 14px; }
  .banner-score { flex-basis: 76px; width: 76px; padding-right: 12px; }
  .banner-score strong { font-size: 36px; }
  .banner-label { font-size: 17px; }
  .banner-summary { font-size: 13px; }
  .scale-legend { gap: 8px 14px; font-size: 11px; }
  .record-item { gap: 8px; }
  .answer-value { min-width: 62px; font-size: 12px; }
  .app-footer { font-size: 11px; }
}

@media (max-width: 480px) {
  .app-shell { padding: 0 8px; }
  .header-nav { width: 100%; }
  .nav-btn { flex: 1; text-align: center; padding: 8px 6px; font-size: 13px; }
  .card { padding: 18px 14px; }
  .notice { padding: 14px; font-size: 13px; }
  .chips { gap: 7px; }
  .chip { padding: 5px 10px; font-size: 12px; }
  .progress-head { flex-direction: column; gap: 2px; }
  .actions .btn { flex: 1 1 100%; text-align: center; min-height: 46px; }
  .actions .btn-sm { flex: 1 1 auto; min-height: 40px; }
  .status-banner { flex-direction: column; align-items: flex-start; gap: 12px; }
  .banner-score { width: auto; flex: none; border-right: none; border-bottom: 1px solid rgba(0,0,0,.08); padding: 0 0 10px; text-align: left; }
  .banner-score strong { display: inline; font-size: 38px; }
  .banner-score span { display: inline; margin-left: 8px; }
  .nav-grid { grid-template-columns: repeat(6, 1fr); }
  .record-item .level-badge { font-size: 12px; }
  .resource-name { min-width: 100%; }
  .dim-head { flex-direction: column; gap: 0; }
  .dim-score { font-size: 12px; }
}

/* ---------- admin ---------- */
.toolbar { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.search-field { flex: 1 1 220px; max-width: 320px; }
.toolbar-stats { margin-left: auto; color: var(--text-muted); font-size: 13px; align-self: center; }
.detail-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
@media (max-width: 760px) {
  .toolbar-stats { margin-left: 0; width: 100%; }
  .search-field { max-width: none; }
}

@media print {
  body { background: #fff; }
  .header-nav, .actions, .toast-root, .app-footer { display: none !important; }
  .card { box-shadow: none; break-inside: avoid; }
}
