:root {
  --green: #2e7d5b;
  --green-deep: #1f5c41;
  --green-soft: #e6f2ec;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2a30;
  --muted: #6b7c84;
  --line: #e3e9ec;
  --red: #d9534f;
  --amber: #e8a13a;
  --blue: #3b82c4;
  --shadow: 0 2px 12px rgba(31, 90, 65, 0.08);
}

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

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  color: #fff;
  padding: 14px 18px 12px;
  display: flex;
  align-items: baseline;
  gap: 10px;
  box-shadow: var(--shadow);
}
.app-header .brand { font-size: 19px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.app-header .sub { font-size: 12px; opacity: 0.85; }

main { padding: 14px 14px 84px; max-width: 720px; margin: 0 auto; }

.page { display: none; animation: fade .25s ease; }
.page.active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.card {
  background: var(--card);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
.card h3 { margin: 0 0 12px; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.card .hint { color: var(--muted); font-size: 12.5px; }

/* 表单 */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field .row { display: flex; gap: 10px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  background: #fbfdfc;
  color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--green-soft);
  border-color: var(--green);
}
.unit { color: var(--muted); font-size: 12px; margin-left: 4px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  background: var(--green);
  color: #fff;
  width: 100%;
  transition: filter .15s;
}
.btn:active { filter: brightness(0.92); }
.btn.ghost { background: #fff; color: var(--green); border: 1px solid var(--green); }
.btn.danger { background: #fff; color: var(--red); border: 1px solid var(--red); }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; }

/* 提醒条 */
.reminder {
  background: var(--green-soft);
  border: 1px solid #bfe0cf;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}
.reminder.due { background: #fff3d6; border-color: #f0c878; }
.reminder .t { font-weight: 700; color: var(--green-deep); }
.reminder.due .t { color: var(--amber); }

/* 记录列表 */
.rec-list { list-style: none; margin: 0; padding: 0; }
.rec-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 4px; border-bottom: 1px dashed var(--line); font-size: 14px;
}
.rec-item:last-child { border-bottom: none; }
.rec-item .date { color: var(--muted); font-size: 12.5px; }
.rec-item .vals { font-weight: 600; }
.rec-item .del { color: var(--red); background: none; border: none; font-size: 13px; cursor: pointer; }

/* 趋势图 */
.chart-wrap { overflow-x: auto; }
canvas { width: 100%; height: 200px; display: block; }
.chart-controls { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.chip {
  padding: 6px 12px; border-radius: 20px; font-size: 13px;
  background: #eef2f0; color: var(--muted); border: none; cursor: pointer;
}
.chip.active { background: var(--green); color: #fff; }

/* 知识卡片 */
.know-card {
  background: var(--card); border-radius: 14px; padding: 15px 16px; margin-bottom: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--line); cursor: pointer;
}
.know-card .tag {
  display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 20px;
  background: var(--green-soft); color: var(--green-deep); margin-bottom: 8px;
}
.know-card h4 { margin: 0 0 6px; font-size: 16px; }
.know-card p { margin: 0; color: var(--muted); font-size: 13.5px; }

/* 弹窗 */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 50;
  display: none; align-items: flex-end; justify-content: center;
}
.modal-mask.show { display: flex; }
.modal {
  background: #fff; width: 100%; max-width: 720px; max-height: 86vh; overflow-y: auto;
  border-radius: 18px 18px 0 0; padding: 20px 20px 30px; animation: up .25s ease;
}
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
.modal h2 { margin: 0 0 4px; font-size: 20px; }
.modal .tag { display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 20px; background: var(--green-soft); color: var(--green-deep); margin-bottom: 12px; }
.modal-body { font-size: 15px; }
.modal-body h3 { font-size: 16px; margin: 18px 0 6px; color: var(--green-deep); }
.modal-body p { margin: 6px 0; }
.modal-body .warn { background: #fff4f3; border-left: 3px solid var(--red); padding: 8px 12px; border-radius: 6px; color: #a33; font-size: 13.5px; }
.modal-body .ok { background: var(--green-soft); border-left: 3px solid var(--green); padding: 8px 12px; border-radius: 6px; color: var(--green-deep); font-size: 13.5px; }
.modal-close { float: right; background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1; }

/* 我的 */
.disclaimer {
  background: #fff8ec; border: 1px solid #f0d9a8; border-radius: 10px;
  padding: 12px 14px; font-size: 13px; color: #8a6d2f; margin-bottom: 14px;
}
.disclaimer b { color: #6b521f; }

/* 底部导航 */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  display: flex; background: #fff; border-top: 1px solid var(--line);
  box-shadow: 0 -2px 10px rgba(0,0,0,.05); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar button {
  flex: 1; background: none; border: none; padding: 8px 0 6px; cursor: pointer;
  color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.tabbar button .ic { font-size: 20px; }
.tabbar button.active { color: var(--green); font-weight: 700; }

.empty { text-align: center; color: var(--muted); padding: 24px 0; font-size: 14px; }

.section-title { font-size: 13px; color: var(--muted); margin: 4px 2px 8px; font-weight: 600; }
