/* ==================== 基础 ==================== */
:root {
  --bg: #f5f6fb;
  --surface: #ffffff;
  --surface-2: #fafbff;
  --border: #e6e8f0;
  --border-strong: #d3d7e6;
  --text: #1c2033;
  --text-2: #5a6080;
  --text-3: #8b90a8;
  --primary: #4f46e5;
  --primary-dark: #4338ca;
  --primary-soft: #eef2ff;
  --excellent: #10b981;
  --excellent-soft: #e7f8f1;
  --good: #3b82f6;
  --good-soft: #e8f1fe;
  --pass: #f59e0b;
  --pass-soft: #fef4e2;
  --fail: #ef4444;
  --fail-soft: #fdecec;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(28, 32, 51, .05);
  --shadow: 0 2px 8px rgba(28, 32, 51, .06), 0 8px 24px rgba(28, 32, 51, .05);
  --shadow-lg: 0 4px 16px rgba(28, 32, 51, .08), 0 16px 40px rgba(28, 32, 51, .07);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }

.wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* 背景装饰 */
.bg-decor {
  position: fixed;
  inset: 0 0 auto 0;
  height: 380px;
  background:
    radial-gradient(700px 320px at 12% -8%, rgba(99, 102, 241, .16), transparent 65%),
    radial-gradient(620px 300px at 88% 4%, rgba(16, 185, 129, .13), transparent 62%);
  pointer-events: none;
  z-index: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ==================== 顶栏 ==================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  padding-top: 14px;
  padding-bottom: 14px;
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 23px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  box-shadow: 0 4px 14px rgba(79, 70, 229, .3);
  flex-shrink: 0;
}

.brand-text h1 { font-size: 19px; line-height: 1.3; }
.brand-text p { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }

.tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.tab {
  padding: 8px 16px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  transition: all .18s ease;
  white-space: nowrap;
}

.tab:hover { color: var(--text); background: rgba(79, 70, 229, .06); }

.tab.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .28);
}

/* ==================== 视图切换 ==================== */
main { position: relative; z-index: 1; padding: 24px 20px 48px; }

.view { display: none; animation: fadeIn .28s ease; }
.view.is-active { display: block; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ==================== 表单控件 ==================== */
.profile-card { padding: 20px 22px; margin-bottom: 22px; }

.profile-row {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
  align-items: flex-end;
}

.field-group { display: flex; flex-direction: column; gap: 7px; }
.field-group.grow { flex: 1; min-width: 220px; }

.field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: .04em;
}

.seg {
  display: inline-flex;
  padding: 3px;
  gap: 3px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.seg-btn {
  padding: 7px 20px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-2);
  font-size: 14px;
  font-weight: 600;
  transition: all .18s ease;
}

.seg-btn.is-active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 5px rgba(79, 70, 229, .3);
}

.select {
  padding: 8px 34px 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238b90a8' d='M6 8.5 2 4.5h8z'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.quick-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.btn-ghost {
  padding: 8px 15px;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  transition: all .18s ease;
}

.btn-ghost:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-soft);
}

.btn-danger-ghost:hover {
  border-color: var(--fail);
  color: var(--fail);
  background: var(--fail-soft);
}

.profile-hint {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 13px;
  color: var(--text-2);
}

.profile-hint b { color: var(--text); }

/* ==================== 布局 ==================== */
.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 22px;
  align-items: start;
}

.layout-side {
  position: sticky;
  top: 96px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title h2 { font-size: 17px; }
.section-sub { font-size: 13px; color: var(--text-3); font-weight: 600; }

/* ==================== 输入卡片 ==================== */
.item-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 14px;
}

.item-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.item-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.item-card.is-filled { border-color: #c7d2fe; background: linear-gradient(180deg, #fbfcff, #fff); }
.item-card.is-good { border-color: #a7e8cd; }
.item-card.is-fail { border-color: #f5b8b8; }

.item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}

.item-name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 700;
}

.item-icon { font-size: 17px; }

.weight-tag {
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.item-desc {
  font-size: 12px;
  color: var(--text-3);
  margin-bottom: 11px;
  min-height: 18px;
}

.input-row { display: flex; align-items: center; gap: 9px; }

.field {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text);
  font-size: 15px;
  font-weight: 600;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.field::placeholder { color: #b3b8cd; font-weight: 500; }

.field:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px var(--primary-soft);
}

.field-unit { font-size: 13px; color: var(--text-3); font-weight: 600; flex-shrink: 0; }

/* 双输入（身高/体重） */
.field-pair { display: flex; gap: 8px; }

.field-pair .fp-unit {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 1;
  min-width: 0;
}

.field-pair .fp-unit .field { width: 100%; }
.field-pair .fp-unit .field-unit { flex-shrink: 0; }

/* 得分展示条 */
.item-score {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 11px;
  padding-top: 11px;
  border-top: 1px dashed var(--border);
  min-height: 34px;
}

.item-score-empty { font-size: 12.5px; color: var(--text-3); }

.item-score-value {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.score-num-badge {
  display: inline-flex;
  align-items: baseline;
  gap: 2px;
  padding: 3px 11px;
  border-radius: 20px;
  font-size: 16px;
  font-weight: 800;
}

.score-num-badge small { font-size: 11px; font-weight: 600; }

.g-excellent { background: var(--excellent-soft); color: var(--excellent); }
.g-good { background: var(--good-soft); color: var(--good); }
.g-pass { background: var(--pass-soft); color: #b45309; }
.g-fail { background: var(--fail-soft); color: var(--fail); }

.score-threshold { font-size: 12px; color: var(--text-3); }
.score-threshold b { color: var(--text-2); }

.next-hint {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--pass-soft);
  color: #92610a;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
}

.next-hint-none {
  margin-top: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  background: var(--excellent-soft);
  color: #0b7a5c;
  font-size: 12px;
  font-weight: 600;
}

/* ==================== 结果卡 ==================== */
.result-card { padding: 20px 22px; }

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.result-head h2 { font-size: 16px; }

.result-badge {
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-3);
  border: 1px solid var(--border);
}

.result-badge.grade-excellent { background: var(--excellent-soft); color: var(--excellent); border-color: transparent; }
.result-badge.grade-good { background: var(--good-soft); color: var(--good); border-color: transparent; }
.result-badge.grade-pass { background: var(--pass-soft); color: #b45309; border-color: transparent; }
.result-badge.grade-fail { background: var(--fail-soft); color: var(--fail); border-color: transparent; }

.score-display {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
}

.score-main { display: flex; align-items: baseline; gap: 5px; }

.score-num {
  font-size: 46px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -.03em;
  background: linear-gradient(135deg, var(--primary), #7c3aed);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.score-unit { font-size: 12.5px; color: var(--text-3); font-weight: 600; }

.score-bonus { display: flex; align-items: baseline; gap: 3px; }
.score-bonus .plus { font-size: 17px; color: var(--excellent); font-weight: 700; }
.bonus-num { font-size: 22px; font-weight: 800; color: var(--excellent); }

.score-final {
  display: flex;
  align-items: baseline;
  gap: 7px;
  margin-top: 14px;
  padding: 12px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.final-label { font-size: 13px; color: var(--text-2); font-weight: 600; }

.final-num {
  margin-left: auto;
  font-size: 25px;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.final-max { font-size: 12.5px; color: var(--text-3); font-weight: 600; }

/* 进度条 */
.meter { margin-top: 16px; }

.meter-track {
  position: relative;
  height: 9px;
  border-radius: 20px;
  background: #eceef6;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--fail), var(--pass) 45%, var(--good) 72%, var(--excellent));
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
}

.meter-marks span {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(255, 255, 255, .85);
}

.meter-legend {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11.5px;
  color: var(--text-3);
  font-weight: 600;
}

/* 加分明细 */
.bonus-list { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }

.bonus-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--excellent-soft);
  font-size: 12.5px;
}

.bonus-item-name { font-weight: 700; color: #0b7a5c; }
.bonus-item-detail { color: #3f8a76; font-size: 11.5px; }
.bonus-item-val { font-weight: 800; color: var(--excellent); font-size: 15px; white-space: nowrap; }

.result-tips { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }

.result-tip {
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.5;
  font-weight: 500;
}

.result-tip-info { background: var(--primary-soft); color: #3730a3; }
.result-tip-warn { background: var(--pass-soft); color: #92610a; }
.result-tip-error { background: var(--fail-soft); color: #b91c1c; }
.result-tip-good { background: var(--excellent-soft); color: #0b7a5c; }

/* 说明小卡 */
.tips-card { padding: 18px 20px; }
.tips-card h3 { font-size: 14.5px; margin-bottom: 10px; }
.tips-card ul { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.tips-card li { font-size: 12.5px; color: var(--text-2); line-height: 1.55; }
.tips-card b { color: var(--text); }
.tips-card strong { color: var(--primary); }

/* ==================== 标准查询 ==================== */
.filter-card { padding: 20px 22px; margin-bottom: 18px; }

.filter-row { display: flex; gap: 22px; flex-wrap: wrap; margin-bottom: 16px; }

.item-tabs { display: flex; gap: 8px; flex-wrap: wrap; }

.item-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 13.5px;
  font-weight: 600;
  transition: all .18s ease;
}

.item-tab:hover { border-color: var(--primary); color: var(--primary); }

.item-tab.is-active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .25);
}

.table-card { padding: 22px 24px; }

.table-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.table-head h2 { font-size: 17px; }
.table-unit { font-size: 13px; color: var(--text-3); font-weight: 600; }

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.std-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
  min-width: 420px;
}

.std-table th,
.std-table td {
  padding: 9px 12px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.std-table thead th {
  background: var(--surface-2);
  color: var(--text-2);
  font-size: 12.5px;
  font-weight: 700;
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.std-table thead th:first-child { border-radius: 8px 0 0 0; }
.std-table thead th:last-child { border-radius: 0 8px 0 0; }

.std-table tbody tr:hover { background: var(--surface-2); }
.std-table tbody tr:last-child td { border-bottom: 0; }

.std-table td { font-weight: 600; color: var(--text); }

.grade-tag {
  display: inline-block;
  padding: 2px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 700;
}

.grade-tag.grade-excellent { background: var(--excellent-soft); color: var(--excellent); }
.grade-tag.grade-good { background: var(--good-soft); color: var(--good); }
.grade-tag.grade-pass { background: var(--pass-soft); color: #b45309; }
.grade-tag.grade-fail { background: var(--fail-soft); color: var(--fail); }

.score-cell { font-weight: 800; color: var(--primary); font-size: 14.5px; }
.value-cell { font-variant-numeric: tabular-nums; font-weight: 700; }
.value-cell.is-full { color: var(--excellent); }
.value-cell.is-zero { color: var(--text-3); }

.table-note {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
  font-size: 12.5px;
  color: var(--text-2);
  line-height: 1.6;
}

/* ==================== 说明页 ==================== */
.guide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
}

.guide-card { padding: 22px 24px; }
.guide-card h3 { font-size: 16px; margin-bottom: 12px; }
.guide-card h3.mt { margin-top: 24px; }

.guide-desc { font-size: 13px; color: var(--text-2); line-height: 1.6; margin-bottom: 14px; }
.guide-desc.warn {
  margin-top: 12px;
  margin-bottom: 0;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: var(--pass-soft);
  color: #92610a;
}

.guide-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 9px; }
.guide-list li { font-size: 13px; color: var(--text-2); line-height: 1.6; }
.guide-list b { color: var(--text); }

.grade-list { display: flex; flex-direction: column; gap: 8px; }

.grade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 13.5px;
}

.grade-row-range { font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

.source-card { grid-column: 1 / -1; }

/* ==================== 页脚 ==================== */
.site-footer {
  border-top: 1px solid var(--border);
  background: rgba(255, 255, 255, .6);
  padding: 20px 0;
  position: relative;
  z-index: 1;
}

.site-footer p { font-size: 12.5px; color: var(--text-3); text-align: center; }

/* ==================== 响应式 ==================== */
@media (max-width: 1000px) {
  .layout { grid-template-columns: 1fr; }
  .layout-side { position: static; }
  .item-grid { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
}

@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .wrap { padding: 0 14px; }
  main { padding: 18px 14px 40px; }
  .header-inner { padding: 12px 0; }
  .brand-text h1 { font-size: 17px; }
  .brand-text p { display: none; }
  .tabs { width: 100%; }
  .tab { flex: 1; padding: 8px 6px; font-size: 13px; }
  .profile-card, .filter-card, .table-card, .guide-card, .result-card { padding: 16px 17px; }
  .profile-row { gap: 16px; }
  .field-group.grow { min-width: 100%; }
  .quick-actions .btn-ghost { flex: 1; }
  .item-grid { grid-template-columns: 1fr; }
  .score-num { font-size: 40px; }
  .seg-btn { padding: 7px 16px; }
}

@media print {
  .site-header, .site-footer, .tabs, .quick-actions, .result-tips { display: none; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
}
