:root {
  --bg: #f5f7f4;
  --panel: #fff;
  --ink: #14251c;
  --muted: #657368;
  --line: #d8e3dc;
  --green: #2c8360;
  --green-dark: #164b35;
  --mint: #e8f5ee;
  --yellow: #f4bd4f;
  --orange: #e67b45;
  --red: #c94b4b;
  --shadow: 0 16px 38px rgba(35, 54, 44, 0.08);
  --blue: #4f7ea8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
  background:
    linear-gradient(180deg, #fbfcfa 0, var(--bg) 260px),
    var(--bg);
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
}

.app {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  background: #102419;
  color: #f7fbf7;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

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

.brand-mark {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: linear-gradient(135deg, #74c69d, #2f7d59);
  display: grid;
  place-items: center;
  font-weight: 800;
}

.brand h1 {
  margin: 0;
  font-size: 19px;
  line-height: 1.2;
}

.brand p {
  margin: 4px 0 0;
  color: #b6c5bb;
  font-size: 12px;
}

.nav {
  display: grid;
  gap: 10px;
}

.nav button {
  border: 0;
  min-height: 48px;
  border-radius: 8px;
  background: transparent;
  color: #d7e2da;
  text-align: left;
  padding: 12px 15px;
  cursor: pointer;
  font-size: 16px;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav button:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav button.active {
  background: #eaf5ee;
  color: #173d2a;
  font-weight: 700;
  transform: translateX(2px);
}

.notice {
  margin-top: auto;
  padding: 16px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: #cbd9cf;
  font-size: 13px;
  line-height: 1.75;
}

main {
  padding: 36px 40px 52px;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 28px;
}

.topbar h2 {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p,
.muted {
  color: var(--muted);
  line-height: 1.75;
}

.topbar p {
  display: none;
}

.status {
  margin-top: 4px;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(35, 54, 44, 0.06);
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(480px, 1.08fr) minmax(380px, 0.92fr);
  gap: 22px;
}

#dashboard .dashboard-grid {
  align-items: stretch;
}

.section-gap {
  margin-top: 18px;
}

#trends .dashboard-grid {
  grid-template-columns: minmax(560px, 1.18fr) minmax(380px, 0.82fr);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 26px;
}

#dashboard .dashboard-grid > .card:last-child {
  background: #fffdf8;
  border-color: #eadfc8;
}

.card h3 {
  margin: 0 0 18px;
  font-size: 24px;
  line-height: 1.25;
}

.block-title {
  margin: 24px 0 12px;
  font-size: 20px;
  line-height: 1.3;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.score-card {
  display: grid;
  grid-template-columns: 152px minmax(0, 1fr);
  align-items: center;
  gap: 30px;
  min-height: 240px;
  background:
    linear-gradient(90deg, #ffffff 0, #ffffff 62%, #f2faf5 100%);
  border-color: #cfe4d8;
}

.score-ring {
  width: 152px;
  height: 152px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #fff 58%, transparent 59%),
    conic-gradient(var(--green) 0 72%, #e7ece7 72% 100%);
  display: grid;
  place-items: center;
  text-align: center;
}

.score-ring strong {
  display: block;
  font-size: 38px;
  line-height: 1;
}

.score-ring span {
  color: var(--muted);
  font-size: 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #fff6df;
  color: #8a5b08;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
}

.pill.low {
  background: var(--mint);
  color: var(--green-dark);
}

.pill.high,
.pill.red {
  background: #fff0ee;
  color: #9b3c34;
}

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

.btn,
.ghost {
  border-radius: 8px;
  min-height: 46px;
  padding: 11px 18px;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.btn {
  border: 0;
  font-weight: 700;
}

.btn.primary {
  background: var(--green);
  color: #fff;
  box-shadow: 0 10px 22px rgba(44, 131, 96, 0.18);
}

.btn.primary.submitted,
.btn.primary:disabled {
  background: #8fa79a;
  color: #fff;
  cursor: default;
  box-shadow: none;
}

.btn.secondary,
.ghost {
  background: #eef4ef;
  color: var(--green-dark);
  border: 1px solid #cfe0d3;
}

.ghost {
  min-height: 34px;
  padding: 6px 10px;
}

.btn:hover,
.ghost:hover {
  transform: translateY(-1px);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(170px, 1fr));
  gap: 16px;
  margin-top: 0;
}

.action-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.action-panel .action-card:only-child {
  grid-column: 1 / -1;
}

.action-card {
  min-height: 158px;
  box-shadow: 0 12px 28px rgba(35, 54, 44, 0.06);
}

.action-card span {
  display: inline-flex;
  width: fit-content;
  margin-bottom: 10px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--mint);
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 800;
}

.action-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 21px;
}

.action-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.task-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

.task-actions button {
  min-height: 38px;
  border-radius: 8px;
  padding: 8px 13px;
  cursor: pointer;
  font-weight: 700;
}

.task-done {
  border: 0;
  background: var(--green);
  color: #fff;
}

.task-later {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--green-dark);
}

.action-card.completed {
  opacity: 0.72;
  background: #f3f6f4;
}

.primary-action {
  background: linear-gradient(135deg, #ffffff 0, #eef8f3 100%);
  border-color: #b9dac8;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  min-height: 124px;
  box-shadow: 0 10px 24px rgba(35, 54, 44, 0.05);
}

.metric.highlight {
  background: #eef8f3;
  border-color: #b8dbc7;
}

.metric span {
  color: var(--muted);
  font-size: 15px;
}

.metric strong {
  display: block;
  margin: 10px 0 14px;
  font-size: 30px;
  line-height: 1;
}

.metric i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--mint);
}

.alert-list,
.summary {
  display: grid;
  gap: 14px;
}

.deduction-list {
  display: grid;
  gap: 12px;
}

.deduction-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 16px;
  align-items: center;
  padding: 15px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.deduction-item span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.deduction-item strong:last-child {
  color: #a85b24;
  font-size: 18px;
}

.deduction-empty {
  padding: 20px;
  border-radius: 8px;
  background: #eef8f3;
  color: var(--green-dark);
  line-height: 1.7;
}

.alert {
  padding: 16px;
  border-radius: 8px;
  border: 1px solid #f0dfb6;
  background: #fffaf0;
}

.summary-card {
  background: #fffdfa;
}

.coverage {
  margin: -6px 0 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f1f7f3;
  color: var(--green-dark);
  font-size: 14px;
  font-weight: 700;
}

.summary-card .alert {
  padding: 18px;
}

.alert.orange {
  border-color: #f0c6ad;
  background: #fff4ed;
}

.alert.red {
  border-color: #e5b8b8;
  background: #fff2f2;
}

.alert strong {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
}

.alert p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.form-grid label,
fieldset {
  display: grid;
  gap: 10px;
  margin: 0;
  font-weight: 700;
  font-size: 15px;
}

input,
select {
  min-height: 52px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 0 15px;
  font-size: 16px;
}

input:focus,
select:focus {
  outline: 3px solid rgba(44, 131, 96, 0.12);
  border-color: #8fc8ac;
}

fieldset {
  border: 1px solid #d3e2d9;
  border-radius: 8px;
  padding: 22px;
}

legend {
  padding: 0 6px;
}

.full {
  grid-column: 1 / -1;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 4px;
}

.chips label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 44px;
  padding: 8px 13px;
  font-weight: 700;
  background: #fff;
  color: #355144;
}

.field-label {
  margin-top: 6px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.danger-label {
  color: #9b3c34;
}

.danger-chips label {
  border-color: #e5b8b8;
  background: #fff7f6;
}

.urgent-warning {
  padding: 13px 15px;
  border: 1px solid #e2a5a1;
  border-radius: 8px;
  background: #fff0ee;
  color: #8f302a;
  font-weight: 700;
  line-height: 1.65;
}

.result {
  margin-top: 16px;
}

.result.compact {
  margin-top: 12px;
}

.result-box {
  border-radius: 8px;
  border: 1px solid #d3e3d7;
  background: #eef5ef;
  padding: 20px;
  display: grid;
  gap: 10px;
}

.result-box strong {
  font-size: 18px;
}

.result-box p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 15px;
}

.form-section {
  background: #fbfdfb;
  border-radius: 8px;
  padding: 22px;
  position: relative;
}

.form-section legend {
  font-size: 19px;
  font-weight: 900;
  color: var(--green-dark);
  padding: 0 9px;
  background: #fbfdfb;
}

.section-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.section-fields label {
  align-content: start;
}

.checkin-card {
  max-width: none;
  width: 100%;
  border-color: #cfe4d8;
}

.checkin-streak {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  padding: 15px 18px;
  border: 1px solid #b8dbc7;
  border-radius: 8px;
  background: #eef8f3;
}

.checkin-streak span {
  color: var(--muted);
  font-weight: 700;
}

.checkin-streak strong {
  color: var(--green-dark);
  font-size: 25px;
}

.checkin-streak small {
  margin-left: auto;
  color: var(--muted);
}

.checkin-card .form-grid {
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

.checkin-card .form-section:nth-of-type(1),
.checkin-card .form-section:nth-of-type(2) {
  grid-column: 1 / -1;
}

.checkin-card .actions.full {
  grid-column: 1 / -1;
  justify-content: flex-end;
  padding-top: 2px;
}

.checkin-card .actions {
  justify-content: flex-start;
}

.detail-toggle {
  min-height: 46px;
  border: 1px dashed #a9cdb8;
  border-radius: 8px;
  background: #f3faf6;
  color: var(--green-dark);
  cursor: pointer;
  font-weight: 800;
}

.detail-section[hidden] {
  display: none;
}

.quick-fields {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.checkin-card .btn.primary {
  min-width: 180px;
}

.section-fields.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.risk-explain {
  margin: 14px 0 18px;
  padding: 13px 14px;
  border-radius: 8px;
  background: #f8fbf9;
  border: 1px solid var(--line);
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
}

.risk-result-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin: 4px 0;
}

.risk-result-item {
  padding: 14px;
  border-radius: 8px;
  background: #fbfdfb;
  border: 1px solid var(--line);
}

.risk-result-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.risk-result-item strong {
  display: block;
  font-size: 17px;
}

.bars {
  min-height: 390px;
}

.trend-tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.trend-tabs button {
  min-height: 44px;
  border: 1px solid #cfe0d3;
  border-radius: 8px;
  background: #f6faf7;
  color: var(--green-dark);
  cursor: pointer;
  font-weight: 700;
}

.trend-tabs button.active {
  border-color: var(--green);
  background: var(--green);
  color: #fff;
}

.profile-note {
  margin-bottom: 16px;
  padding: 15px 17px;
  border: 1px solid #cfe0d3;
  border-radius: 8px;
  background: #f2f8f4;
  color: var(--green-dark);
  line-height: 1.7;
}

.bmi-reference {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.bmi-reference span {
  font-weight: 800;
}

.bmi-reference strong {
  color: var(--green-dark);
  font-size: 26px;
}

.bmi-reference small {
  color: var(--muted);
}

.trend-card {
  padding-bottom: 22px;
}

.trend-card h3,
.summary-card h3 {
  margin-bottom: 20px;
}

.chart {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 14px;
  padding-top: 8px;
}

.chart-scale {
  display: grid;
  grid-template-rows: repeat(5, 1fr);
  color: var(--muted);
  font-size: 13px;
  text-align: right;
  padding-top: 8px;
  padding-bottom: 42px;
}

.chart-plot {
  height: 318px;
  display: grid;
  grid-template-columns: repeat(7, minmax(48px, 1fr));
  align-items: end;
  gap: 20px;
  padding: 8px 12px 42px;
  border-left: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background:
    repeating-linear-gradient(
      to top,
      transparent 0,
      transparent 55px,
      #edf2ee 56px
    );
}

.bar {
  width: min(58px, 100%);
  justify-self: center;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, #76bd98, #2f7d59);
  position: relative;
  min-height: 24px;
  box-shadow: inset 0 -10px 16px rgba(20, 72, 48, 0.16);
}

.bar.medium {
  background: linear-gradient(180deg, #f6d47a, #e0a637);
}

.bar.high {
  background: linear-gradient(180deg, #ed9b70, #d86438);
}

.bar-value {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--ink);
  font-weight: 800;
  font-size: 14px;
  white-space: nowrap;
}

.bar-label {
  position: absolute;
  bottom: -32px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.chart-legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 16px;
  color: var(--muted);
  font-size: 14px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-legend i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.legend-low {
  background: var(--green);
}

.legend-medium {
  background: var(--yellow);
}

.legend-high {
  background: var(--orange);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    position: relative;
  }

  .nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  main {
    padding: 20px;
  }

  .dashboard-grid,
  .score-card,
  .form-grid,
  .action-panel,
  .trend-tabs,
  .risk-result-grid,
  .section-fields,
  .section-fields.three {
    grid-template-columns: 1fr;
  }

  .checkin-card .form-section:nth-of-type(1),
  .checkin-card .form-section:nth-of-type(2),
  .checkin-card .form-section:nth-of-type(3),
  .checkin-card .actions.full {
    grid-column: 1 / -1;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #trends .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .nav,
  .metric-grid,
  .trend-tabs {
    grid-template-columns: 1fr;
  }

  .checkin-streak,
  .bmi-reference {
    align-items: flex-start;
    flex-direction: column;
  }

  .checkin-streak small {
    margin-left: 0;
  }

  .score-ring {
    margin: 0 auto;
  }

  .card {
    padding: 20px;
  }

  .chart-plot {
    grid-template-columns: repeat(7, minmax(28px, 1fr));
    gap: 10px;
  }
}
