﻿:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #16a34a;
  --primary-dark: #15803d;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warn: #d97706;
  --warn-bg: #fffbeb;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.08);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}
#app { max-width: 720px; margin: 0 auto; padding: 16px; }

/* 卡片与通用 */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px; }
.card h3 { margin: 0 0 10px; font-size: 16px; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: Consolas, Menlo, monospace; }

/* 按钮 */
.btn { display: inline-block; border: none; border-radius: 8px; padding: 9px 16px; font-size: 14px; cursor: pointer; background: var(--primary); color: #fff; text-decoration: none; }
.btn:hover { background: var(--primary-dark); }
.btn.secondary { background: #e5e7eb; color: var(--text); }
.btn.secondary:hover { background: #d1d5db; }
.btn.danger { background: var(--danger); }
.btn.danger:hover { background: #b91c1c; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* 表单 */
input, select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; background: #fff; color: var(--text);
}
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
.field { margin-bottom: 10px; }
.form-row { display: flex; gap: 10px; }
.form-row > div { flex: 1; }

/* 导航 */
nav.tabs { display: flex; gap: 6px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 6px; margin-bottom: 14px; position: sticky; top: 8px; z-index: 10; }
nav.tabs button { flex: 1; border: none; background: transparent; padding: 8px 4px; border-radius: 8px; font-size: 14px; cursor: pointer; color: var(--muted); }
nav.tabs button.active { background: var(--primary); color: #fff; font-weight: 600; }

/* 横幅 */
.banner { padding: 10px 14px; border-radius: 10px; margin-bottom: 12px; font-size: 14px; font-weight: 600; }
.banner.warn { background: var(--warn-bg); color: var(--warn); border: 1px solid #fcd34d; }
.banner.danger { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.banner.info { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }

/* 统计行 */
.summary { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { flex: 1; min-width: 100px; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; text-align: center; }
.stat .num { font-size: 20px; font-weight: 700; }
.stat .lbl { font-size: 12px; color: var(--muted); }
.stat.red .num { color: var(--danger); }
.stat.green .num { color: var(--primary); }

/* 餐卡 */
.meal-card { background: #fff; border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.meal-card.over-limit { border-left-color: var(--danger); border-color: #fecaca; background: #fffafa; }
.meal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.meal-title { font-weight: 700; font-size: 15px; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge.red { background: var(--danger-bg); color: var(--danger); border: 1px solid #fecaca; }
.badge.green { background: #f0fdf4; color: var(--primary-dark); border: 1px solid #bbf7d0; }
.meal-img { width: 100%; max-height: 220px; object-fit: cover; border-radius: 8px; margin: 6px 0; }
.food-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0; }
.food-tag { background: #f3f4f6; border-radius: 6px; padding: 2px 8px; font-size: 13px; }
.food-tag b { color: var(--danger); }
.meal-actions { display: flex; gap: 8px; margin-top: 8px; }

/* 上传 */
.upload-area { border: 2px dashed var(--border); border-radius: 10px; padding: 16px; text-align: center; cursor: pointer; }
.upload-area:hover { border-color: var(--primary); }
.upload-area img.preview { max-width: 100%; max-height: 260px; border-radius: 8px; }
.food-item-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.food-item-row input:first-child { flex: 2; }
.food-item-row input { flex: 1; }

/* 群组 */
.group-list-item { display: flex; justify-content: space-between; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 10px; margin-bottom: 8px; background: #fff; }
.feed-item { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 12px; margin-bottom: 10px; }
.feed-user { font-weight: 700; }
.like-btn { border: 1px solid var(--border); background: #fff; border-radius: 20px; padding: 4px 12px; cursor: pointer; font-size: 14px; }
.like-btn.liked { background: #fef2f2; border-color: #fecaca; color: var(--danger); }

/* 日历 */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-dow { text-align: center; font-size: 12px; color: var(--muted); padding: 4px 0; }
.cal-cell { aspect-ratio: 1; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 13px; cursor: pointer; background: #fff; }
.cal-cell.empty { border-color: transparent; background: transparent; cursor: default; }
.cal-cell .mark { font-size: 18px; line-height: 1.2; }
.cal-cell .kcal { font-size: 10px; color: var(--muted); }
.cal-cell.today { border-color: var(--primary); background: #f0fdf4; }

/* 回顾 */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.chart-wrap { overflow-x: auto; }
svg { display: block; }

/* 设置 */
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 认证 */
.auth-box { max-width: 380px; margin: 60px auto; }
.auth-tabs { display: flex; margin-bottom: 16px; }
.auth-tabs button { flex: 1; padding: 10px; border: none; background: #fff; cursor: pointer; font-size: 15px; border-bottom: 2px solid var(--border); }
.auth-tabs button.active { border-bottom-color: var(--primary); color: var(--primary); font-weight: 700; }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: center; justify-content: center; z-index: 100; padding: 16px; }
.modal { background: #fff; border-radius: 12px; max-width: 480px; width: 100%; padding: 18px; max-height: 85vh; overflow-y: auto; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }

/* ===== 日历图标强化 ===== */
.cal-cell { position: relative; }
.cal-cell .mark { font-size: 30px; line-height: 1.1; }
.cal-cell .day-num { font-size: 13px; font-weight: 600; }
.cal-cell .kcal { font-size: 10px; color: var(--muted); line-height: 1.2; }
.cal-cell.mark-flower { background: #fffbeb; border-color: #f59e0b; box-shadow: inset 0 0 0 1px #fde68a; }
.cal-cell.mark-check { background: #f0fdf4; border-color: #16a34a; box-shadow: inset 0 0 0 1px #bbf7d0; }
.cal-cell.mark-cross { background: #fef2f2; border-color: #dc2626; box-shadow: inset 0 0 0 1px #fecaca; }
.cal-cell.today { border-width: 2px; }

/* ===== 移动端适配 ===== */
@media (max-width: 640px) {
  #app { padding: 10px; }
  .auth-box { margin: 24px auto; }
  nav.tabs { padding: 4px; gap: 4px; top: 6px; }
  nav.tabs button { font-size: 13px; padding: 9px 2px; }
  .card { padding: 12px; }
  .banner { font-size: 13px; padding: 9px 12px; }
  .stat { padding: 8px 6px; }
  .stat .num { font-size: 17px; }
  .form-row { flex-wrap: wrap; }
  .form-row > div { flex: 1 1 45%; min-width: 120px; }
  input, select, textarea { font-size: 16px; }
  .btn { padding: 10px 14px; }
  .meal-img { max-height: 180px; }
  .food-tag { font-size: 12px; }
  .cal-grid { gap: 5px; }
  .cal-cell .mark { font-size: 26px; }
  .cal-cell .day-num { font-size: 12px; }
  .chart-wrap svg { min-width: 480px; }
  .stats-grid { gap: 6px; }
  .modal { padding: 14px; }
}

@media (max-width: 380px) {
  .cal-cell .mark { font-size: 22px; }
  .cal-cell .kcal { display: none; }
  nav.tabs button { font-size: 12px; }
  .summary .stat { min-width: 80px; }
}
