/* styles.css — 轻食记风格：清新、卡片式、移动优先 */
:root {
  --bg: #f0f7f4;
  --card: #ffffff;
  --primary: #22c55e;
  --primary-dark: #16a34a;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --orange: #fff7ed;
  --green: #f0fdf4;
  --teal: #f0fdfa;
  --blue: #eff6ff;
  --purple: #faf5ff;
}
* { box-sizing: border-box; }
body {
  margin: 0; font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg); color: var(--text); font-size: 14px;
}
.app-header {
  background: var(--card); padding: 12px 16px; display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--border);
}
.brand { font-size: 18px; font-weight: 700; color: var(--primary-dark); }
.header-meta { font-size: 12px; color: var(--muted); }
.app-nav {
  display: flex; gap: 6px; padding: 10px; background: var(--card); border-bottom: 1px solid var(--border);
  overflow-x: auto; white-space: nowrap;
}
.app-nav button {
  border: none; background: #f3f4f6; padding: 8px 12px; border-radius: 16px; font-size: 13px; color: var(--muted); cursor: pointer;
}
.app-nav button.active { background: var(--primary); color: #fff; font-weight: 600; }
main { max-width: 680px; margin: 0 auto; padding: 12px; padding-bottom: 40px; }
.view { display: none; }
.view.active { display: block; }
.card {
  background: var(--card); border-radius: 14px; padding: 16px; margin-bottom: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.card h3 { margin: 0 0 12px; font-size: 16px; }
/* 顶部常驻一周日期条 */
.week-bar {
  display: flex; align-items: center; gap: 6px; padding: 8px 10px;
  background: var(--card); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 9;
}
.week-bar .wb-nav {
  flex: none; border: none; background: #f3f4f6; font-size: 20px; color: var(--primary-dark);
  width: 30px; height: 42px; border-radius: 10px; cursor: pointer;
}
.week-days { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.week-day {
  flex: 1; min-width: 38px; text-align: center; padding: 6px 2px; border-radius: 10px;
  cursor: pointer; background: #f3f4f6;
}
.week-day .d-num { font-size: 15px; font-weight: 600; line-height: 1.2; }
.week-day .d-wk { font-size: 11px; color: var(--muted); }
.week-day.today { box-shadow: 0 0 0 2px var(--primary); }
.week-day.selected { background: var(--primary); color: #fff; }
.week-day.selected .d-wk { color: #fff; }
.week-day.future { opacity: .5; }
/* 饮食/运动页当前选中日期标签 */
.day-tag {
  font-size: 13px; color: var(--primary-dark); font-weight: 600;
  background: #f0fdf4; padding: 4px 10px; border-radius: 12px;
}
.stats-range-label {
  font-size: 12px; color: var(--muted); text-align: center; margin: 0 0 12px;
}
.date-bar {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px;
}
.date-bar button {
  background: var(--card); border: none; font-size: 24px; color: var(--primary-dark); cursor: pointer; padding: 4px 14px; border-radius: 10px;
}
.date-bar h2 { margin: 0; font-size: 17px; font-weight: 600; }
.cards-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
.cards-row.five { grid-template-columns: repeat(2, 1fr); }
@media (min-width: 520px) { .cards-row.five { grid-template-columns: repeat(3, 1fr); } }
.stat-card {
  background: var(--card); border-radius: 14px; padding: 14px; text-align: left;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.stat-card.orange { background: var(--orange); }
.stat-card.green { background: var(--green); }
.stat-card.teal { background: var(--teal); }
.stat-card.blue { background: var(--blue); }
.stat-card.purple { background: var(--purple); }
.stat-card .icon { font-size: 22px; margin-bottom: 4px; }
.stat-card .label { font-size: 12px; color: var(--muted); }
.stat-card .value { font-size: 22px; font-weight: 700; margin-top: 2px; }
.stat-card .value small { font-size: 12px; font-weight: 400; color: var(--muted); }
.stat-card .sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.weight-input-row { display: flex; align-items: center; gap: 8px; }
.weight-input-row input {
  flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
}
.unit { color: var(--muted); }
.sub-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.sub-card {
  background: #f9fafb; border-radius: 12px; padding: 12px; text-align: center;
}
.sub-card .label { font-size: 12px; color: var(--muted); }
.sub-card .value { font-size: 20px; font-weight: 700; }
.sub-card .hint { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bmi-scale { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; }
.bmi-tag { font-size: 11px; padding: 4px 8px; border-radius: 8px; background: #f3f4f6; }
.bmi-tag.normal { background: #dcfce7; color: #166534; }
.btn-primary {
  background: var(--primary); color: #fff; border: none; padding: 10px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600; cursor: pointer; white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary {
  background: #fff; color: var(--primary-dark); border: 1px solid var(--primary); padding: 10px 16px;
  border-radius: 10px; font-size: 14px; cursor: pointer; display: block; width: 100%; margin-top: 8px;
}
.section-header { display: flex; justify-content: space-between; align-items: center; }
.form-row { display: flex; gap: 8px; margin-bottom: 10px; }
.form-row input, .form-row select {
  flex: 1; padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
}
.form-row.four { display: grid; grid-template-columns: repeat(2, 1fr); }
.manual-fields {
  background: #f9fafb; border-radius: 10px; padding: 10px; margin-bottom: 10px;
}
.hint { font-size: 12px; color: var(--muted); margin: 4px 0; }
.record-list { list-style: none; padding: 0; margin: 0; }
.record-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.record-list li button {
  background: transparent; border: none; color: #ef4444; cursor: pointer; font-size: 12px;
}
.macro-totals {
  display: grid; grid-template-columns: repeat(4, 1fr); text-align: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.macro-totals div span { display: block; font-size: 11px; color: var(--muted); }
.macro-totals div b { display: block; font-size: 18px; }
.total-bar {
  display: flex; justify-content: space-between; align-items: center; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
}
.total-bar b { font-size: 20px; color: var(--primary-dark); }
.range-toggle { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; }
.range-toggle button {
  border: none; background: #e5e7eb; padding: 8px 18px; border-radius: 18px; cursor: pointer;
}
.range-toggle button.active { background: var(--primary); color: #fff; }
.backup-grid { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 520px) { .backup-grid { grid-template-columns: 1fr 1fr; } }
.backup-grid textarea {
  width: 100%; margin-top: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 12px;
}
label { display: block; margin: 10px 0; font-size: 14px; color: #374151; }
label input, label select {
  width: 100%; margin-top: 4px; padding: 10px; border: 1px solid var(--border); border-radius: 10px; font-size: 14px;
}
.hint-box { background: #f0fdf4; border-left: 4px solid var(--primary); padding: 12px; border-radius: 8px; margin-top: 14px; font-size: 13px; }
#advisor-card ul { margin: 0; padding-left: 18px; }
#advisor-card li { margin: 6px 0; font-size: 13px; }
footer { text-align: center; color: var(--muted); font-size: 12px; padding: 20px; }

/* 周条每日记录完成度小圆点 */
.week-day .dot {
  width: 7px; height: 7px; border-radius: 50%; margin: 3px auto 0;
  background: #cbd5e1;
}
.week-day .dot.partial { background: #f97316; }
.week-day .dot.full { background: #22c55e; }

/* 月历视图 */
.month-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.month-head h3 { margin: 0; font-size: 16px; }
.month-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font-size: 11px; color: var(--muted); margin-bottom: 6px; }
.month-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.month-cell {
  background: #f3f4f6; border-radius: 10px; padding: 6px 4px; min-height: 54px;
  font-size: 12px; cursor: pointer; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start; text-align: center;
}
.month-cell.empty { background: transparent; cursor: default; }
.month-cell .m-num { font-size: 12px; font-weight: 600; color: var(--text); }
.month-cell .m-w { font-size: 12px; color: var(--primary-dark); font-weight: 600; margin-top: 2px; }
.month-cell.empty .m-num { color: transparent; }
.month-cell.today { box-shadow: 0 0 0 2px var(--primary); }
.month-cell.selected { outline: 2px solid var(--primary-dark); }
.month-cell.comp-1 { background: #ffedd5; }
.month-cell.comp-2 { background: #dcfce7; }
.month-legend { display: flex; gap: 14px; justify-content: center; font-size: 12px; color: var(--muted); margin-top: 10px; }
.month-legend .dot, .legend-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot.gray, .legend-dot.gray { background: #cbd5e1; }
.dot.orange, .legend-dot.orange { background: #f97316; }
.dot.green, .legend-dot.green { background: #22c55e; }

/* 跨设备同步区 */
.sync-status { background: #f9fafb; border-radius: 10px; padding: 10px; font-size: 13px; margin: 10px 0; color: var(--text); }
.sync-status.bound { background: #f0fdf4; color: var(--primary-dark); border: 1px solid #bbf7d0; }
