:root {
  --bg: #eefaf3;
  --bg2: #e6f4fb;
  --green: #2fb87a;
  --green-d: #1f9c65;
  --blue: #46b6e8;
  --blue-d: #2f9bd0;
  --ink: #2f3e46;
  --muted: #7c8a93;
  --card: #ffffff;
  --red: #e8523f;
  --green-up: #2eaf6a;
  --line: #e4eee9;
  --shadow: 0 8px 24px rgba(47, 184, 122, 0.10);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--ink);
  min-height: 100vh;
  font-size: 15px;
}

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px; backdrop-filter: blur(6px);
  background: rgba(255,255,255,0.65);
  position: sticky; top: 0; z-index: 20;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 20px; font-weight: 800; letter-spacing: .5px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.hello-user { color: var(--muted); font-size: 13px; }

.container { max-width: 1080px; margin: 0 auto; padding: 16px 16px 60px; }

/* 目标卡 */
.goal-card {
  display: flex; flex-wrap: wrap; gap: 18px; align-items: center;
  background: linear-gradient(135deg, #ffffff, #f3fbf7);
  border-radius: 20px; padding: 18px 20px; box-shadow: var(--shadow);
  margin-bottom: 18px; border: 1px solid #e7f4ec;
}
.goal-left { display: flex; align-items: center; gap: 16px; }
.goal-ring {
  width: 92px; height: 92px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px; color: var(--green-d);
  background: conic-gradient(var(--green) 0deg, #e6f4ec 0deg);
  position: relative;
}
.goal-ring::before {
  content: ""; position: absolute; inset: 8px; border-radius: 50%; background: #fff;
}
.goal-ring span { position: relative; z-index: 1; }
.goal-meta { display: flex; flex-direction: column; gap: 4px; }
.goal-row { display: flex; gap: 10px; font-size: 13px; color: var(--muted); }
.goal-row b { color: var(--ink); font-size: 15px; }
.goal-right { flex: 1; min-width: 220px; }
.goal-comment {
  font-size: 16px; font-weight: 700; color: var(--green-d);
  background: #ecfaf2; padding: 10px 14px; border-radius: 12px; line-height: 1.5;
}
.goal-cheer { margin-top: 8px; color: var(--muted); font-size: 14px; }
.goal-basis { margin-top: 10px; font-size: 13px; color: var(--muted); }
.basis-btn {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 20px; padding: 4px 12px; margin-left: 6px; cursor: pointer; font-size: 12px;
}
.basis-btn.active { background: var(--green); color: #fff; border-color: var(--green); }

/* 图表区 */
.charts { margin-bottom: 22px; }
.range-tabs {
  display: inline-flex; gap: 6px; background: #fff; padding: 5px;
  border-radius: 14px; box-shadow: var(--shadow); margin-bottom: 14px;
}
.range-btn {
  border: none; background: transparent; color: var(--muted);
  padding: 7px 16px; border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600;
}
.range-btn.active { background: var(--green); color: #fff; }

.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-box {
  background: #fff; border-radius: 18px; padding: 14px 14px 6px;
  box-shadow: var(--shadow); border: 1px solid #eef5f1;
}
.chart-box.full { grid-column: 1 / -1; margin-top: 14px; }
.chart-box h3 { margin: 2px 4px 8px; font-size: 15px; }
.chart-box h3 small { color: var(--muted); font-weight: 500; font-size: 12px; }
.chart { width: 100%; height: 280px; }

/* 录入区 */
.section-title { font-size: 18px; margin: 6px 2px 14px; }
.entry-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  background: #fff; border-radius: 18px; padding: 16px;
  box-shadow: var(--shadow); border: 1px solid #eef5f1;
}
.card-head { font-weight: 800; font-size: 16px; margin-bottom: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.field input, .inline input, .inline select, select {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font-size: 15px; color: var(--ink); background: #fbfdfc; width: 100%;
}
.field input:focus, .inline input:focus, select:focus { outline: 2px solid #cdeede; border-color: var(--green); }
.inline { display: flex; gap: 8px; margin-bottom: 10px; align-items: center; }
.inline select { flex: 1.4; }
.inline input { flex: 1; }
.calc-out { font-size: 13px; color: var(--green-d); font-weight: 700; white-space: nowrap; }

.btn-add {
  border: none; background: var(--green); color: #fff; border-radius: 10px;
  padding: 0 14px; font-size: 18px; cursor: pointer; min-width: 42px; height: 42px;
}
.btn-add.wide { width: 100%; height: 40px; font-size: 15px; margin-bottom: 10px; }
.btn-cam {
  width: 100%; border: 1px dashed var(--blue); color: var(--blue-d); background: #f1f9fe;
  border-radius: 12px; padding: 11px; font-size: 14px; font-weight: 600; cursor: pointer; margin-top: 6px;
}
.item-list { list-style: none; padding: 0; margin: 8px 0; max-height: 160px; overflow: auto; }
.item-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 10px; background: #f6fbf8; border-radius: 10px; margin-bottom: 6px; font-size: 13px;
}
.item-list li .rm { color: var(--red); cursor: pointer; font-weight: 700; margin-left: 10px; }
.summary-line { font-size: 13px; color: var(--muted); margin-top: 4px; }
.summary-line b { color: var(--ink); }
.btn-save {
  width: 100%; border: none; background: linear-gradient(135deg, var(--green), var(--blue));
  color: #fff; font-size: 17px; font-weight: 800; padding: 14px; border-radius: 14px;
  cursor: pointer; margin-top: 14px; box-shadow: 0 8px 20px rgba(47,184,122,0.25);
}
.btn-ghost {
  border: 1px solid var(--line); background: #fff; color: var(--muted);
  border-radius: 10px; padding: 9px 14px; cursor: pointer; font-size: 14px;
}

/* 弹窗 */
.modal {
  position: fixed; inset: 0; background: rgba(30,50,40,0.45);
  display: none; align-items: center; justify-content: center; z-index: 50; padding: 16px;
}
.modal.show { display: flex; }
.modal-box {
  background: #fff; border-radius: 18px; padding: 18px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25); max-height: 92vh; overflow: auto;
}
.modal-box.wide { max-width: 460px; }
.modal-head { font-weight: 800; font-size: 17px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.x { border: none; background: #f1f5f3; border-radius: 8px; width: 30px; height: 30px; cursor: pointer; }
.cam-stage { background: #111; border-radius: 14px; overflow: hidden; aspect-ratio: 4/3; display: flex; align-items: center; justify-content: center; }
.cam-stage video, .cam-stage img { width: 100%; height: 100%; object-fit: cover; }
.cam-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.cam-actions .btn-add, .cam-actions .btn-ghost, .cam-actions .btn-save { flex: 1; min-width: 90px; height: 42px; font-size: 14px; }
.recog-result { font-size: 14px; background: #f3fbf7; border-radius: 12px; padding: 12px; margin-bottom: 10px; display: none; }
.recog-result.show { display: block; }
.recog-card { display: block; }
.recog-title { font-weight: 800; font-size: 15px; margin-bottom: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; }
.recog-src { font-style: normal; font-weight: 700; font-size: 12px; color: #2fb87a; background: #e6f7ef; border-radius: 8px; padding: 2px 8px; }
.recog-demo { font-style: normal; font-weight: 700; font-size: 12px; color: #b9791f; background: #fdf3e0; border-radius: 8px; padding: 2px 8px; }
.rfield { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; font-size: 13px; color: var(--muted); }
.rfield span { white-space: nowrap; }
.rfield input { flex: 1; max-width: 160px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; text-align: right; }
.rfield input[readonly] { background: #eef4f1; color: var(--green-d); font-weight: 700; }
.rnote { font-size: 12px; color: var(--muted); background: #fff; border-radius: 8px; padding: 6px 8px; margin-bottom: 10px; }
.recog-btns { display: flex; gap: 8px; }
.recog-btns .btn-add { flex: 1; font-size: 15px; padding: 0; }
.api-settings { font-size: 13px; color: var(--muted); margin-top: 6px; }
.api-settings summary { cursor: pointer; }
.api-settings .field { margin-top: 10px; }

/* Toast */
.toast {
  position: fixed; bottom: 30px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 30px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: .3s; z-index: 80;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* 响应式 */
@media (max-width: 720px) {
  .chart-grid, .entry-grid { grid-template-columns: 1fr; }
  .chart { height: 240px; }
  .container { padding: 12px 12px 50px; }
  .goal-card { flex-direction: column; align-items: flex-start; }
  .goal-right { width: 100%; }
  .brand { font-size: 17px; }
  .hello-user { display: none; }
}

/* 健康小工具 / 数据备份 */
.tool-out { display: flex; flex-direction: column; gap: 8px; font-size: 15px; margin: 4px 0 12px; }
.tool-out b { font-size: 18px; color: var(--green-d); }
.tag { font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 10px; margin-left: 4px; }
.tag-ok { background: #e3f7ec; color: #1f9c65; }
.tag-low { background: #e7f0fb; color: #2f6fd0; }
.tag-warn { background: #fdf0db; color: #c9871a; }
.tag-bad { background: #fde4e0; color: #c23a26; }
.tool-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 6px 0 0; }

