:root {
  --bg: #f5f7fb;
  --card: #ffffff;
  --primary: #2f6df6;
  --primary-d: #1f53c7;
  --ok: #1faa6b;
  --warn: #e8820c;
  --text: #1f2430;
  --muted: #8a93a6;
  --line: #e7ebf2;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
}
.view { min-height: 100vh; }
.hidden { display: none !important; }

/* 登录 */
.login-card {
  max-width: 360px;
  margin: 12vh auto 0;
  padding: 28px 24px;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(20, 40, 90, 0.08);
}
.login-card h1 { margin: 0 0 4px; font-size: 22px; }
.login-card .sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.login-card input {
  width: 100%; padding: 11px 12px; margin-bottom: 12px;
  border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
}
.login-card button {
  width: 100%; padding: 11px; border: 0; border-radius: 10px;
  background: var(--primary); color: #fff; font-size: 15px; cursor: pointer;
}
.login-card button:hover { background: var(--primary-d); }
.hint { margin: 16px 0 8px; color: var(--muted); font-size: 12px; }
.demo-row { display: flex; flex-wrap: wrap; gap: 8px; }
.demo-row button {
  flex: 1 1 28%; padding: 8px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; cursor: pointer; font-size: 13px;
}
.demo-row button:hover { border-color: var(--primary); color: var(--primary); }
.err { color: #d83a3a; font-size: 13px; min-height: 18px; margin-top: 8px; }

/* 主视图 */
.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 18px; background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 17px; }
.who { margin-left: auto; color: var(--muted); font-size: 13px; }
.ghost { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 6px 12px; cursor: pointer; }

/* 布局：侧边栏 + 内容 */
.layout { display: flex; min-height: calc(100vh - 57px); }
.sidebar {
  width: 224px; flex: 0 0 224px; background: var(--card);
  border-right: 1px solid var(--line); padding: 12px 10px; overflow-y: auto;
}
.nav-group { margin-bottom: 14px; }
.nav-title {
  font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: .5px;
  padding: 6px 8px; text-transform: none;
}
.nav-item {
  padding: 9px 10px; border-radius: 9px; cursor: pointer; font-size: 14px;
  color: var(--text); margin-bottom: 2px; user-select: none;
}
.nav-item:hover { background: #f0f4fc; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.content { flex: 1; overflow-y: auto; }
.pane { padding: 18px; max-width: 880px; margin: 0 auto; }

/* 分类内容页 */
.cat-head { margin-bottom: 14px; }
.cat-head h2 { margin: 0 0 8px; font-size: 20px; }
.subs { display: flex; flex-wrap: wrap; gap: 6px; }
.sub-chip {
  font-size: 12px; padding: 3px 10px; border-radius: 20px;
  background: #eef2fb; color: var(--primary);
}
textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 14px; font-family: inherit; resize: vertical; margin-top: 4px;
}


/* 卡片 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 12px; }

/* 任务 */
.task { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.task:last-child { border-bottom: 0; }
.task .info { flex: 1; }
.task .name { font-weight: 600; }
.task .meta { color: var(--muted); font-size: 12px; margin-top: 2px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 20px; background: #eef2fb; color: var(--primary); margin-right: 6px; }
.group-title { font-weight: 700; margin: 18px 0 6px; color: var(--text); }
.btn-done { background: var(--ok); color: #fff; border: 0; border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.btn-undo { background: #fff; color: var(--muted); border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
.done-tag { color: var(--ok); font-size: 13px; }

/* 表单 */
label { display: block; font-size: 13px; color: var(--muted); margin: 10px 0 4px; }
input[type=text], input[type=number], input[type=date], input[type=password] {
  width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 15px;
}
.btn-primary { background: var(--primary); color: #fff; border: 0; border-radius: 10px; padding: 10px 16px; cursor: pointer; margin-top: 12px; }
.note { font-size: 12px; color: var(--muted); line-height: 1.6; }

/* 小类 / 任务 */
.add-row { display: flex; gap: 8px; margin-top: 10px; }
.add-row input { flex: 1; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; }
.btn-sm { padding: 9px 12px; font-size: 13px; margin-top: 0; }
.subcat-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 12px; background: #fbfcfe; }
.subcat-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.subcat-name { font-weight: 600; font-size: 15px; }
.btn-x { border: 1px solid var(--line); background: #fff; color: #d83a3a; border-radius: 8px; padding: 4px 10px; cursor: pointer; font-size: 12px; }
.btn-x:hover { background: #fff0f0; }
.btn-x-sm { border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 13px; padding: 2px 6px; }
.btn-x-sm:hover { color: #d83a3a; }
.task-list { display: flex; flex-direction: column; gap: 6px; }
.ctask { display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; }
.ctask:hover { background: #f1f5fd; }
.ctask-left { display: flex; align-items: center; gap: 8px; flex: 1; cursor: pointer; font-size: 14px; }
.ctask-title { font-size: 14px; }
.ctask-title.done { text-decoration: line-through; color: var(--muted); }
.sub-grp { font-size: 13px; font-weight: 600; color: var(--primary); margin: 10px 0 4px; }

/* 曲线 */
.chart-wrap { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; }

/* 基线评估页 */
.base-profile .add-row { align-items: center; }
.base-profile label.inline { display: inline-block; margin: 0 8px 0 0; width: auto; color: var(--text); font-size: 13px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 14px; margin-top: 4px; }
.form-grid > div { min-width: 0; }
.g-preview { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.g-age { font-size: 12px; color: #5b6678; background: #eef2f7; padding: 4px 10px; border-radius: 8px; }
.g-band { font-size: 12px; padding: 4px 10px; border-radius: 8px; }
.g-band.ok { background: #e8f6ee; color: #1f7a4d; }
.g-band.low { background: #fff4e5; color: #b9720a; }
.g-band.high { background: #fdeaea; color: #c0392b; }

/* toast */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%);
  background: #1f2430; color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; z-index: 99;
}

/* 首页（沿用 首页代码.txt 视觉样式） */
.home-head {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; padding: 14px 22px; border: 1px solid #d8dee8; border-radius: 14px;
}
.home-brand { display: flex; align-items: center; gap: 10px; }
.home-logo {
  width: 32px; height: 32px; border-radius: 9px; background: linear-gradient(135deg, #185FA5, #534AB7);
  color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.home-title { font-size: 16px; font-weight: 700; }
.home-meta { display: flex; align-items: center; gap: 8px; font-size: 12px; color: #5b6678; }
.home-avatar {
  width: 28px; height: 28px; border-radius: 50%; background: #E6F1FB; color: #185FA5;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.card.home-today { border-top: 4px solid #185FA5; margin-top: 12px; }
.home-today-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.home-sec-title { font-size: 16px; font-weight: 700; }
.home-date { font-size: 12px; color: #5b6678; }
.home-today-body { display: flex; gap: 18px; align-items: center; }
.ring { width: 78px; height: 78px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.ring-in { width: 58px; height: 58px; border-radius: 50%; background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-num { font-size: 17px; font-weight: 700; color: #185FA5; }
.ring-sub { font-size: 10px; color: #5b6678; }
.home-rows { flex: 1; display: flex; flex-direction: column; }
.hrow { display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-bottom: 1px solid #f1f3f7; cursor: pointer; border-radius: 6px; }
.hrow:last-child { border-bottom: 0; }
.hrow:hover { background: #f7f9fc; }
.ck { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid #cdd5e0; display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; color: #fff; }
.ck-on { background: #185FA5; border-color: #185FA5; }
.hrow-name { flex: 1; font-size: 13px; }
.cat-tag { font-size: 11px; padding: 1px 8px; border-radius: 99px; flex-shrink: 0; }
.reward { font-size: 11px; color: #c08a00; flex-shrink: 0; }
.reward-praise { color: #5b6678; }
.home-cats-title { font-size: 15px; font-weight: 700; margin: 18px 0 12px; }
.home-cats { display: flex; gap: 12px; }
.home-cat-col { flex: 1; background: #fff; border-radius: 12px; border-top: 3px solid #185FA5; padding: 12px 14px; }
.home-cat-g { font-size: 13px; font-weight: 700; margin-bottom: 8px; }
.home-cat-item { display: flex; align-items: center; gap: 8px; padding: 6px 4px; font-size: 12.5px; border-bottom: 1px solid #f3f4f7; cursor: pointer; border-radius: 6px; }
.home-cat-item:last-child { border-bottom: 0; }
.home-cat-item:hover { color: #185FA5; background: #f7f9fc; }
.home-cat-idx { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; border-radius: 5px; font-size: 10px; font-weight: 700; flex-shrink: 0; }

/* 家庭执行与激励 仪表盘 */
.goal-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.goal-cell { background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.goal-k { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.goal-v { font-size: 15px; font-weight: 700; line-height: 1.4; }
.goal-pct { font-size: 12px; color: #185FA5; font-weight: 700; margin-left: 4px; }
.exec-bar { position: relative; height: 22px; background: #eef2f7; border-radius: 99px; overflow: hidden; margin: 10px 0 4px; }
.exec-bar-fill { height: 100%; background: linear-gradient(90deg, #185FA5, #534AB7); border-radius: 99px; }
.exec-bar-txt { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; color: #fff; font-weight: 700; }

.roster-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin-top: 6px; }
.roster-card { background: #fff; border: 1px solid var(--line); border-top: 3px solid #185FA5; border-radius: 12px; padding: 12px 14px; }
.roster-top { display: flex; align-items: center; justify-content: space-between; }
.roster-name { font-size: 14px; font-weight: 700; }
.roster-tag { font-size: 11px; padding: 1px 8px; border-radius: 99px; font-weight: 600; }
.roster-meta { font-size: 11.5px; color: var(--muted); margin: 6px 0; }
.roster-tasks { font-size: 12px; color: #5b6678; line-height: 1.5; }

.intro { background: #f7f9fc; border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; margin: 6px 0 12px; font-size: 13px; line-height: 1.6; }
.intro p { margin: 4px 0; }
.points-big { font-size: 15px; }
.points-big b { color: #c08a00; font-size: 18px; }

.reward-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin-top: 6px; }
.reward-card { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; }
.reward-name { font-size: 14px; font-weight: 700; }
.reward-desc { font-size: 12px; color: var(--muted); margin: 4px 0 10px; flex: 1; }
.reward-foot { display: flex; align-items: center; justify-content: space-between; }
.reward-cost { font-size: 14px; font-weight: 700; color: #c08a00; }
.reward-foot button:disabled { background: #c7ced9; cursor: not-allowed; }

.hist-list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.hist-row { display: flex; align-items: center; gap: 12px; font-size: 13px; padding: 7px 8px; border-bottom: 1px solid #f1f3f7; border-radius: 6px; }
.hist-row:last-child { border-bottom: 0; }
.hist-row > span:first-child { flex: 1; }
.hist-cost { color: #c08a00; font-weight: 700; }
.hist-date { color: var(--muted); font-size: 12px; }
.home-foot { padding: 12px 4px 4px; font-size: 11px; color: #9aa5b5; }

/* 营养管理仪表盘 */
.nutri-checks { display: flex; flex-direction: column; gap: 8px; margin: 4px 0 10px; }
.nutri-check { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; background: #fff; transition: .15s; }
.nutri-check:hover { border-color: var(--brand); background: #f5f9ff; }
.nutri-check.done { cursor: default; background: #f1f8f3; border-color: #bfe3c7; }
.nutri-check.done:hover { background: #f1f8f3; }
.nc-name { font-size: 14px; font-weight: 700; flex: 1; }
.nc-meta { font-size: 12px; color: var(--muted); }
.nc-state { font-size: 12px; font-weight: 600; color: var(--muted); }
.nutri-check.done .nc-state { color: #3B6D11; }

.nutri-form { flex-wrap: wrap; align-items: flex-end; }
.nutri-form label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 3px; min-width: 88px; }
.nutri-form input, .nutri-form select { width: 100%; }
label.block { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); gap: 3px; margin: 10px 0; }

.rate-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.rate-cell { background: #f7f9fc; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.rate-k { font-size: 12px; color: var(--muted); }
.rate-v { font-size: 20px; font-weight: 800; color: var(--brand); margin: 2px 0 6px; }
.rate-bar { height: 7px; background: #e7ebf2; border-radius: 99px; overflow: hidden; }
.rate-fill { height: 100%; background: var(--brand); border-radius: 99px; }
.mini-title { font-size: 12px; color: var(--muted); margin: 14px 0 4px; font-weight: 600; }

.bmi-v { font-size: 28px; font-weight: 800; }
.bmi-unit { font-size: 13px; font-weight: 500; color: var(--muted); }
.bmi-meta { font-size: 12.5px; color: var(--muted); margin: 2px 0 8px; }

/* 每日打卡项管理（家庭执行与激励） */
.rule-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 8px; background: #f7f9fc; }
.rule-name { font-size: 13.5px; font-weight: 600; }
.rule-f { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; color: var(--muted); }
.rule-f input { width: 70px; padding: 4px 6px; }
.rule-f .rule-sup { width: 96px; }
.rule-add { align-items: center; }
.rule-add input, .rule-add select { flex: 0 1 auto; }

/* 打卡项管理：下拉与锁定态 */
.rule-f select { width: 96px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 6px; background: #fff; }
.done-tag.muted { background: #eef2f7; color: #8a93a0; font-weight: 500; }
.nutri-check.locked { opacity: .55; cursor: not-allowed; }

/* 营养打卡关联提示 & 日记自动徽标 */
.nc-link { font-size: 11px; color: #185FA5; background: #E6F1FB; padding: 1px 6px; border-radius: 6px; }
.auto-badge { display: inline-block; font-size: 10px; color: #3B6D11; background: #EAF3DE; border: 1px solid #C0DD97; border-radius: 6px; padding: 0 5px; margin-left: 4px; vertical-align: middle; }
.nutri-form label { position: relative; }

/* 双向积分：总览与明细 */
.po-neg { color: #d23b3b !important; }
.po-warn { color: #b8860b; background: #fdf6e3; border: 1px solid #f0e2b8; border-radius: 8px; padding: 6px 9px; margin-top: 10px; }
.po-ok { color: #3B6D11; background: #eef7e6; border: 1px solid #cfe3b0; border-radius: 8px; padding: 6px 9px; margin-top: 10px; }
.pts-plus { color: #3B6D11; font-weight: 700; }
.pts-minus { color: #d23b3b; font-weight: 700; }

/* ===== 移动端适配（手机/窄屏）===== */
@media (max-width: 768px) {
  /* 登录页：卡片贴边、输入框放大到 16px 防止 iOS 自动缩放、按钮更好点 */
  .view { min-height: 100dvh; }
  .login-card {
    max-width: 100%;
    margin: 7vh auto 0;
    padding: 22px 18px;
    border-radius: 14px;
  }
  .login-card h1 { font-size: 20px; }
  .login-card input { font-size: 16px; padding: 13px 12px; }
  .login-card button { font-size: 16px; padding: 13px; }
  .demo-row { gap: 6px; }
  .demo-row button { flex: 1 1 44%; padding: 10px; }

  /* 主视图：侧边栏从左侧固定改为顶部横向滚动，内容占满 */
  .layout { flex-direction: column; min-height: calc(100dvh - 57px); }
  .sidebar {
    width: 100%; flex: 0 0 auto;
    border-right: 0; border-bottom: 1px solid var(--line);
    display: flex; flex-direction: row; flex-wrap: nowrap;
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    gap: 4px; padding: 8px 10px;
  }
  .nav-group {
    display: flex; flex-direction: row; align-items: center;
    margin-bottom: 0; flex: 0 0 auto; gap: 4px;
  }
  .nav-title { display: none; }
  .nav-item {
    white-space: nowrap; margin-bottom: 0; padding: 8px 12px; flex: 0 0 auto;
  }
  .content { overflow-y: visible; }
  .pane { padding: 14px; max-width: 100%; }
  .topbar { flex-wrap: wrap; gap: 8px; }
  .who { margin-left: 0; width: 100%; order: 3; }
}

/* 超窄屏（小手机）进一步收紧 */
@media (max-width: 380px) {
  .login-card { margin: 5vh auto 0; padding: 18px 14px; }
  .demo-row button { flex: 1 1 100%; }
  .home-cats { flex-direction: column; }
  .goal-grid, .reward-grid, .roster-grid, .rate-grid { grid-template-columns: 1fr; }
}

