/* =========================================================
   《AI家庭营养师》全局样式
   中国移动蓝色系 · 卡片式 · 移动端优先
   ========================================================= */
:root {
  --primary: #0A66C2;
  --primary-light: #00A0E9;
  --primary-soft: #E8F3FC;
  --accent: #FF6A00;
  --accent-soft: #FFF1E6;
  --success: #22A06B;
  --warning: #F5A623;
  --danger: #E5484D;
  --bg: #F4F7FB;
  --card: #FFFFFF;
  --text: #1F2A3A;
  --text-2: #66788F;
  --text-3: #9AA9BC;
  --border: #E5ECF5;
  --radius: 16px;
  --shadow: 0 2px 12px rgba(10, 102, 194, 0.06);
  --shadow-lg: 0 8px 30px rgba(10, 102, 194, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 10px 16px;
  display: flex; align-items: center; gap: 14px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--text); }
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; box-shadow: 0 4px 10px rgba(10,102,194,.3);
}
.nav-links { display: flex; gap: 4px; margin-left: 8px; flex: 1; }
.nav-links a {
  padding: 7px 14px; border-radius: 20px; color: var(--text-2);
  font-size: 14px; font-weight: 500; transition: all .2s;
}
.nav-links a:hover { background: var(--primary-soft); color: var(--primary); }
.nav-links a.active { background: var(--primary); color: #fff; box-shadow: 0 4px 10px rgba(10,102,194,.25); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.point-pill {
  background: linear-gradient(135deg, #FF8A00, var(--accent));
  color: #fff; padding: 5px 12px; border-radius: 20px;
  font-size: 13px; font-weight: 600; display: flex; align-items: center; gap: 5px;
  box-shadow: 0 4px 10px rgba(255,106,0,.25);
}
.user-chip { display: flex; align-items: center; gap: 8px; }
.user-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--primary-soft); color: var(--primary);
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.logout-btn { color: var(--text-3); font-size: 13px; }

/* ---------- 布局 ---------- */
.container { max-width: 1080px; margin: 0 auto; padding: 20px 16px 90px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 18px; flex-wrap: wrap; gap: 8px; }
.page-title { font-size: 22px; font-weight: 700; }
.page-sub { color: var(--text-2); font-size: 13px; margin-top: 4px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); border: 1px solid var(--border);
  padding: 18px; margin-bottom: 16px;
}
.card-title { font-size: 16px; font-weight: 700; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card-title .tag { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); }
.card-title .tag.orange { background: var(--accent-soft); color: var(--accent); }
.card-title .tag.green { background: #E6F6EE; color: var(--success); }

/* ---------- 快捷入口 ---------- */
.quick-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.quick-item {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 12px; text-align: center; cursor: pointer; transition: all .2s;
  box-shadow: var(--shadow);
}
.quick-item:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary-light); }
.quick-icon {
  width: 48px; height: 48px; border-radius: 14px; margin: 0 auto 10px;
  display: flex; align-items: center; justify-content: center; font-size: 24px;
}
.quick-item:nth-child(1) .quick-icon { background: #E8F3FC; }
.quick-item:nth-child(2) .quick-icon { background: #FFF1E6; }
.quick-item:nth-child(3) .quick-icon { background: #E6F6EE; }
.quick-item:nth-child(4) .quick-icon { background: #F3EEFF; }
.quick-name { font-weight: 600; font-size: 14px; }
.quick-desc { color: var(--text-3); font-size: 11px; margin-top: 3px; }

/* ---------- 通用网格 ---------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- 食材徽章 ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border-radius: 20px; font-size: 13px;
  background: var(--primary-soft); color: var(--primary); font-weight: 500;
}
.chip.green { background: #E6F6EE; color: var(--success); }
.chip.orange { background: #FEF4E5; color: var(--warning); }
.chip.red { background: #FDEBEC; color: var(--danger); }
.chip.gray { background: #EFF2F7; color: var(--text-2); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; cursor: pointer; font-size: 14px; font-weight: 600;
  padding: 10px 20px; border-radius: 12px; transition: all .2s;
  font-family: inherit;
}
.btn-primary { background: linear-gradient(135deg, var(--primary), var(--primary-light)); color: #fff; box-shadow: 0 4px 12px rgba(10,102,194,.3); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(10,102,194,.4); }
.btn-accent { background: linear-gradient(135deg, #FF8A00, var(--accent)); color: #fff; box-shadow: 0 4px 12px rgba(255,106,0,.3); }
.btn-accent:hover { transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1.5px solid var(--primary); color: var(--primary); }
.btn-outline:hover { background: var(--primary-soft); }
.btn-ghost { background: var(--bg); color: var(--text-2); }
.btn-ghost:hover { background: #E9EFF6; }
.btn-sm { padding: 6px 14px; font-size: 13px; border-radius: 10px; }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none !important; }
.btn-block { width: 100%; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 6px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 14px; border: 1.5px solid var(--border);
  border-radius: 12px; font-size: 14px; font-family: inherit; color: var(--text);
  background: #FBFDFF; transition: border-color .2s; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary-light); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- 成员卡片 ---------- */
.member-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; box-shadow: var(--shadow);
}
.member-avatar {
  width: 56px; height: 56px; border-radius: 50%; margin: 0 auto 10px;
  background: var(--primary-soft); display: flex; align-items: center; justify-content: center;
  font-size: 28px;
}
.member-name { font-weight: 700; font-size: 15px; }
.member-meta { color: var(--text-3); font-size: 12px; margin-top: 2px; }
.member-goal { margin-top: 8px; }

/* ---------- 菜谱卡片 ---------- */
.recipe-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: all .2s;
}
.recipe-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.recipe-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.recipe-name { font-weight: 700; font-size: 16px; }
.recipe-type { font-size: 11px; background: var(--primary-soft); color: var(--primary); padding: 2px 8px; border-radius: 8px; font-weight: 600; }
.recipe-reason { color: var(--text-2); font-size: 13px; margin-bottom: 8px; }
.recipe-meta { display: flex; gap: 12px; flex-wrap: wrap; color: var(--text-3); font-size: 12px; margin-bottom: 8px; }
.recipe-ing { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.recipe-method { font-size: 13px; color: var(--text-2); background: var(--bg); border-radius: 10px; padding: 8px 12px; }

/* ---------- 周计划 ---------- */
.day-block { border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; background: var(--card); }
.day-head {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff; padding: 8px 16px; font-weight: 700; font-size: 14px;
  display: flex; justify-content: space-between; align-items: center;
}
.day-head .date { opacity: .85; font-weight: 400; font-size: 12px; }
.day-meal { display: flex; padding: 12px 16px; gap: 12px; align-items: flex-start; border-top: 1px dashed var(--border); }
.day-meal:first-child { border-top: none; }
.meal-icon { font-size: 20px; width: 36px; height: 36px; border-radius: 10px; background: var(--bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.meal-body { flex: 1; }
.meal-name { font-weight: 600; font-size: 14px; }
.meal-reason { color: var(--text-3); font-size: 12px; }

/* ---------- 采购清单 ---------- */
.shop-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--border); font-size: 14px; }
.shop-item:last-child { border-bottom: none; }
.shop-name { flex: 1; font-weight: 500; }
.shop-amount { color: var(--text-2); font-size: 13px; }

/* ---------- 打卡 ---------- */
.checkin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.checkin-item {
  background: var(--card); border: 1.5px solid var(--border); border-radius: var(--radius);
  padding: 16px; text-align: center; cursor: pointer; transition: all .2s; box-shadow: var(--shadow);
}
.checkin-item:hover { border-color: var(--primary-light); transform: translateY(-2px); }
.checkin-item.done { border-color: var(--success); background: linear-gradient(135deg, #F2FBF6, #E6F6EE); }
.checkin-icon { font-size: 30px; margin-bottom: 6px; }
.checkin-name { font-weight: 600; font-size: 14px; }
.checkin-points { color: var(--accent); font-size: 12px; font-weight: 600; margin-top: 4px; }
.checkin-status { margin-top: 8px; font-size: 12px; }
.checkin-status .ok { color: var(--success); font-weight: 600; }

/* ---------- 商城 ---------- */
.mall-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.mall-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); transition: all .2s;
}
.mall-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.mall-cover {
  height: 90px; display: flex; align-items: center; justify-content: center;
  font-size: 44px; background: linear-gradient(135deg, var(--primary-soft), #F5FAFF);
}
.mall-body { padding: 14px 16px; }
.mall-name { font-weight: 700; font-size: 15px; }
.mall-desc { color: var(--text-3); font-size: 12px; margin: 4px 0 10px; min-height: 32px; }
.mall-bottom { display: flex; align-items: center; justify-content: space-between; }
.mall-price { color: var(--accent); font-weight: 700; font-size: 15px; }
.mall-price small { font-size: 11px; color: var(--text-3); font-weight: 400; }

/* ---------- 统计 ---------- */
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.stat-card { background: var(--card); border-radius: var(--radius); padding: 16px; text-align: center; box-shadow: var(--shadow); border: 1px solid var(--border); }
.stat-num { font-size: 26px; font-weight: 800; color: var(--primary); }
.stat-num.orange { color: var(--accent); }
.stat-num.green { color: var(--success); }
.stat-label { color: var(--text-2); font-size: 12px; margin-top: 2px; }

/* ---------- 扫描流程 ---------- */
.scan-steps { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; }
.scan-step { display: flex; align-items: center; gap: 6px; color: var(--text-3); font-size: 13px; }
.scan-step .num {
  width: 24px; height: 24px; border-radius: 50%; background: var(--border);
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px;
}
.scan-step.active { color: var(--primary); font-weight: 600; }
.scan-step.active .num { background: var(--primary); color: #fff; }
.scan-step.done { color: var(--success); }
.scan-step.done .num { background: var(--success); color: #fff; }
.scan-line { flex: 1; height: 2px; background: var(--border); border-radius: 2px; }
.scan-line.done { background: var(--success); }

.demo-fridge {
  border: 2px dashed var(--border); border-radius: var(--radius); padding: 16px;
  cursor: pointer; transition: all .2s; background: var(--card); text-align: center;
}
.demo-fridge:hover, .demo-fridge.selected { border-color: var(--primary); background: var(--primary-soft); }
.demo-fridge.selected { box-shadow: 0 0 0 3px rgba(10,102,194,.15); }
.demo-emoji { font-size: 34px; }
.demo-title { font-weight: 600; margin-top: 6px; font-size: 14px; }
.demo-desc { color: var(--text-2); font-size: 12px; margin-top: 4px; }

/* 识别动画 */
.scanning-anim { text-align: center; padding: 30px; }
.scan-ring {
  width: 72px; height: 72px; border-radius: 50%; margin: 0 auto 14px;
  border: 4px solid var(--primary-soft); border-top-color: var(--primary);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 营养图表 ---------- */
.chart-box { width: 100%; height: 300px; }
.chart-sm { height: 220px; }

/* ---------- Toast ---------- */
#toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: rgba(31,42,58,.92); color: #fff; padding: 10px 22px; border-radius: 12px;
  font-size: 14px; z-index: 999; opacity: 0; pointer-events: none; transition: all .3s;
  max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.ok { background: rgba(34,160,107,.95); }
#toast.err { background: rgba(229,72,77,.95); }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 40px 20px; color: var(--text-3); }
.empty .e-icon { font-size: 44px; margin-bottom: 10px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; color: var(--text-2); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--border); font-size: 12.5px; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--card); border-radius: 20px;
  box-shadow: var(--shadow-lg); border: 1px solid var(--border); padding: 36px 32px;
}
.login-logo {
  width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  display: flex; align-items: center; justify-content: center; font-size: 34px;
  box-shadow: 0 8px 20px rgba(10,102,194,.3);
}
.login-title { text-align: center; font-size: 22px; font-weight: 800; }
.login-sub { text-align: center; color: var(--text-2); font-size: 13px; margin: 6px 0 26px; }
.login-tip { margin-top: 18px; background: var(--primary-soft); border-radius: 10px; padding: 10px 14px; font-size: 12.5px; color: var(--primary); text-align: center; }

/* ---------- 底部移动端导航 ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: rgba(255,255,255,.96); backdrop-filter: blur(10px);
  border-top: 1px solid var(--border); display: none;
  padding-bottom: env(safe-area-inset-bottom);
}
.bottom-nav a {
  flex: 1; text-align: center; padding: 8px 0 6px; color: var(--text-3);
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.bottom-nav a .bi { font-size: 20px; }
.bottom-nav a.active { color: var(--primary); font-weight: 600; }

/* ---------- 响应式 ---------- */
@media (max-width: 860px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .quick-grid { grid-template-columns: repeat(2, 1fr); }
  .nav-links { display: none; }
  .container { padding: 16px 12px 100px; }
  .bottom-nav { display: flex; }
  .stat-row { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .page-title { font-size: 19px; }
  /* 移动端顶栏：更紧凑，隐藏用户名文本，放大触控点 */
  .topbar-inner { gap: 8px; padding: 8px 12px; }
  .brand { font-size: 16px; gap: 7px; }
  .brand-logo { width: 32px; height: 32px; font-size: 18px; }
  .user-chip .small { display: none; }
  .point-pill { font-size: 12px; padding: 5px 11px; }
  .logout-btn { padding: 6px 2px 6px 8px; }
  .bottom-nav a { font-size: 12px; padding: 9px 0 7px; }
  .bottom-nav a .bi { font-size: 22px; }
}
@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
  .mall-grid { grid-template-columns: repeat(2, 1fr); }
  .btn { min-height: 42px; }
}
@media (max-width: 400px) {
  .mall-grid { grid-template-columns: 1fr; }
  .page-sub { display: none; }
}

/* 通用工具 */
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; }
.flex { display: flex; align-items: center; } .between { justify-content: space-between; } .wrap { flex-wrap: wrap; }
.gap8 { gap: 8px; } .gap12 { gap: 12px; }
.text-2 { color: var(--text-2); } .text-3 { color: var(--text-3); }
.small { font-size: 12px; }
.bold { font-weight: 700; }
.center { text-align: center; }
.primary-text { color: var(--primary); }
.accent-text { color: var(--accent); }
.green-text { color: var(--success); }
.red-text { color: var(--danger); }
.hidden { display: none !important; }
