/* =========================================================
   手机端 H5 样式（适老化设计：大字号、大触控区、高对比度）
   ========================================================= */
:root {
  --m-header-h: 56px;
  --m-tabbar-h: 62px;
  /* 适老模式变量，由 JS 切换 --senior 类覆盖 */
  --m-font-base: 16px;
  --m-font-sm: 14px;
  --m-touch-min: 46px;
}

body { background: #f1f5f9; padding-bottom: calc(var(--m-tabbar-h) + env(safe-area-inset-bottom)); }

/* ---------- 顶部栏 ---------- */
.m-header {
  position: sticky; top: 0; z-index: 100;
  background: var(--brand-grad);
  color: #fff; padding-top: env(safe-area-inset-top);
  box-shadow: 0 4px 20px rgba(99, 102, 241, .28);
}
.m-header-in {
  height: var(--m-header-h); display: flex; align-items: center;
  justify-content: space-between; padding: 0 16px;
}
.m-title { font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.m-actions { display: flex; gap: 6px; }
.m-icon-btn {
  position: relative; width: 38px; height: 38px; border-radius: 10px;
  border: none; background: rgba(255, 255, 255, .16); color: #fff;
  font-size: 17px; cursor: pointer; display: grid; place-items: center;
  transition: .15s;
}
.m-icon-btn:active { background: rgba(255, 255, 255, .3); }
.m-badge {
  position: absolute; top: -3px; right: -3px; min-width: 18px; height: 18px;
  border-radius: 9px; background: #f43f5e; color: #fff;
  font-size: 11px; font-weight: 700; display: grid; place-items: center;
  padding: 0 4px; border: 2px solid #5b6ef5;
}

/* ---------- 主区域 ---------- */
.m-main { padding: 14px 14px 80px; min-height: calc(100vh - var(--m-header-h) - var(--m-tabbar-h)); }
.m-loading {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 70px 0; color: var(--muted); font-size: 15px;
}

/* ---------- 底部导航 ---------- */
.m-tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  height: calc(var(--m-tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(255, 255, 255, .97); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  display: flex; align-items: stretch;
}
.m-tab {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; text-decoration: none;
  color: #94a3b8; transition: .15s; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.m-tab-ico { font-size: 21px; line-height: 1; filter: grayscale(1); opacity: .62; transition: .15s; }
.m-tab-txt { font-size: 11.5px; font-weight: 600; }
.m-tab.active { color: var(--brand); }
.m-tab.active .m-tab-ico { filter: none; opacity: 1; transform: translateY(-1px); }

/* ---------- 健康分卡 ---------- */
.score-card {
  background: var(--brand-grad);
  border-radius: 22px; padding: 22px; color: #fff;
  box-shadow: var(--shadow-brand); margin-bottom: 14px;
  position: relative; overflow: hidden;
}
.score-card::after {
  content: ""; position: absolute; right: -28px; top: -28px;
  width: 150px; height: 150px; border-radius: 50%;
  background: rgba(255, 255, 255, .1);
}
.score-card::before {
  content: ""; position: absolute; left: -40px; bottom: -50px;
  width: 170px; height: 170px; border-radius: 50%;
  background: rgba(255, 255, 255, .06);
}
.score-top { display: flex; align-items: flex-start; justify-content: space-between; position: relative; z-index: 1; }
.score-label { font-size: var(--m-font-sm); opacity: .9; margin-bottom: 5px; }
.score-num { font-size: 42px; font-weight: 800; line-height: 1; letter-spacing: -1px; }
.score-num small { font-size: 15px; font-weight: 500; opacity: .78; margin-left: 3px; }
.score-badge {
  padding: 5px 13px; border-radius: 999px; font-size: var(--m-font-sm);
  font-weight: 700; background: rgba(255, 255, 255, .24);
}
.score-dims {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  margin-top: 17px; position: relative; z-index: 1;
}
.score-dim { text-align: center; }
.score-dim .v { font-size: 17px; font-weight: 700; }
.score-dim .k { font-size: 11.5px; opacity: .85; margin-top: 1px; }

/* ---------- 指标卡 ---------- */
.m-card {
  background: #fff; border-radius: 18px; padding: 16px;
  margin-bottom: 12px; box-shadow: var(--shadow);
}
.m-card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.m-card-title { font-size: var(--m-font-base); font-weight: 700; display: flex; align-items: center; gap: 7px; }
.m-card-title .bar-mark { width: 4px; height: 16px; border-radius: 2px; background: var(--brand); }

.metric-row { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.metric-item { flex: 1; min-width: 96px; }
.metric-item .k { font-size: 12.5px; color: var(--muted); margin-bottom: 3px; }
.metric-item .v { font-size: 25px; font-weight: 800; line-height: 1.1; letter-spacing: -.5px; }
.metric-item .v small { font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 2px; }

/* ---------- 分组列表 ---------- */
.m-list { background: #fff; border-radius: 18px; overflow: hidden; box-shadow: var(--shadow); }
.m-list-item {
  display: flex; align-items: center; gap: 13px; padding: 15px 16px;
  border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: .13s;
  min-height: var(--m-touch-min);
}
.m-list-item:active { background: #f8fafc; }
.m-list-item:last-child { border-bottom: none; }
.m-li-ico {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 18px; background: var(--brand-light);
}
.m-li-body { flex: 1; min-width: 0; }
.m-li-title { font-size: var(--m-font-base); font-weight: 600; margin-bottom: 2px; }
.m-li-sub { font-size: 13px; color: var(--muted); }
.m-li-right { font-size: 13.5px; color: var(--muted); flex-shrink: 0; }
.m-li-arrow { color: #cbd5e1; font-size: 17px; flex-shrink: 0; }

/* ---------- 大按钮（录入入口） ---------- */
.m-quick { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 14px; }
.m-quick-btn {
  padding: 18px 14px; border-radius: 18px; border: none; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  font-family: var(--font); font-size: var(--m-font-base); font-weight: 700;
  transition: .18s cubic-bezier(.2,.8,.3,1); box-shadow: var(--shadow);
}
.m-quick-btn:active { transform: scale(.96); }
.m-quick-btn .ico { font-size: 26px; }
.m-quick-bp { background: linear-gradient(135deg, #ffe4e6, #ffd1d6); color: #be123c; }
.m-quick-bg { background: linear-gradient(135deg, #e0f2fe, #c9e8ff); color: #0369a1; }
.m-quick-med { background: linear-gradient(135deg, #d1fae5, #b5f0d2); color: #047857; }
.m-quick-report { background: linear-gradient(135deg, #ede9fe, #ddd0ff); color: #6d28d9; }

/* ---------- 数字键盘录入 ---------- */
.big-input-wrap { text-align: center; padding: 10px 0 18px; }
.big-input-display {
  display: flex; align-items: baseline; justify-content: center; gap: 7px;
  padding: 14px 0; margin-bottom: 8px;
}
.big-input-display .val {
  font-size: 52px; font-weight: 800; letter-spacing: -2px;
  color: var(--ink); min-width: 118px; text-align: center;
  border-bottom: 3px solid var(--brand); line-height: 1.15;
}
.big-input-display .val.empty { color: #cbd5e1; border-bottom-color: #e2e8f0; }
.big-input-display .unit { font-size: 17px; color: var(--muted); font-weight: 600; }

.num-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.num-key {
  height: 54px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; font-size: 23px; font-weight: 600; cursor: pointer;
  font-family: var(--font); color: var(--ink); transition: .12s;
  display: grid; place-items: center;
}
.num-key:active { background: var(--brand-light); border-color: var(--brand); transform: scale(.96); }
.num-key.fn { background: #f8fafc; font-size: 18px; color: var(--ink-2); }
.num-key.del { background: #fef2f2; color: var(--danger); border-color: #fecaca; }

/* ---------- 时段选择 ---------- */
.period-pick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 16px; }
.period-opt {
  padding: 12px 6px; border-radius: 11px; border: 2px solid var(--line);
  background: #fff; text-align: center; cursor: pointer; transition: .14s;
  font-size: var(--m-font-sm); font-weight: 600; color: var(--ink-2);
  font-family: var(--font); min-height: var(--m-touch-min);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
}
.period-opt .ico { font-size: 17px; }
.period-opt.active { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); }
.period-pick.cols-3 { grid-template-columns: repeat(3, 1fr); }
.period-pick.cols-2 { grid-template-columns: repeat(2, 1fr); }

/* ---------- 解读结果卡 ---------- */
.result-card { border-radius: 15px; padding: 18px; margin-bottom: 14px; animation: result-in .3s ease; }
@keyframes result-in { from { opacity: 0; transform: translateY(14px); } }
.result-card.ok { background: linear-gradient(135deg, #d1fae5, #ecfdf5); border: 1.5px solid #6ee7b7; }
.result-card.warn { background: linear-gradient(135deg, #fef3c7, #fffbeb); border: 1.5px solid #fcd34d; }
.result-card.danger { background: linear-gradient(135deg, #fee2e2, #fef2f2); border: 1.5px solid #fca5a5; }
.result-level { font-size: 19px; font-weight: 800; margin-bottom: 9px; display: flex; align-items: center; gap: 8px; }
.result-card.ok .result-level { color: #065f46; }
.result-card.warn .result-level { color: #92400e; }
.result-card.danger .result-level { color: #991b1b; }
.result-value { font-size: 33px; font-weight: 800; letter-spacing: -1px; margin-bottom: 11px; }
.result-advice { font-size: 15px; line-height: 1.72; color: var(--ink-2); }

/* ---------- 服药打卡 ---------- */
.med-item {
  display: flex; align-items: center; gap: 13px; padding: 15px 16px;
  border-bottom: 1px solid #f1f5f9; transition: .16s;
}
.med-item:last-child { border-bottom: none; }
.med-item.taken { background: #f0fdf4; }
.med-item.missed { background: #fef2f2; }
.med-time {
  width: 57px; flex-shrink: 0; text-align: center;
}
.med-time .t { font-size: 17px; font-weight: 800; color: var(--brand); letter-spacing: -.3px; }
.med-time .s { font-size: 11px; color: var(--muted); margin-top: 2px; }
.med-info { flex: 1; min-width: 0; }
.med-name { font-size: var(--m-font-base); font-weight: 700; margin-bottom: 3px; }
.med-detail { font-size: 12.5px; color: var(--muted); }
.med-action { flex-shrink: 0; }
.med-btn {
  padding: 9px 16px; border-radius: 9px; border: none; cursor: pointer;
  font-size: var(--m-font-sm); font-weight: 700; font-family: var(--font);
  background: var(--brand); color: #fff; transition: .15s; min-height: 40px;
}
.med-btn:active { transform: scale(.95); }
.med-btn.done { background: #f1f5f9; color: var(--ok); cursor: default; }
.med-btn.miss { background: #fef2f2; color: var(--danger); cursor: default; }

/* ---------- 预警项 ---------- */
.alert-item {
  display: flex; gap: 12px; padding: 15px 16px;
  border-bottom: 1px solid #f1f5f9;
}
.alert-item:last-child { border-bottom: none; }
.alert-ico {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 17px;
}
.alert-item.danger .alert-ico { background: var(--danger-bg); }
.alert-item.warn .alert-ico { background: var(--warn-bg); }
.alert-body { flex: 1; min-width: 0; }
.alert-title { font-size: var(--m-font-base); font-weight: 700; margin-bottom: 4px; }
.alert-content { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; margin-bottom: 5px; }
.alert-time { font-size: 12px; color: var(--muted); }

/* ---------- 消息项 ---------- */
.msg-item { padding: 15px 16px; border-bottom: 1px solid #f1f5f9; cursor: pointer; transition: .13s; }
.msg-item:last-child { border-bottom: none; }
.msg-item:active { background: #f8fafc; }
.msg-item.unread { background: #f0f9ff; }
.msg-item.unread .msg-title::before {
  content: ""; display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; background: var(--danger); margin-right: 6px; vertical-align: middle;
}
.msg-title { font-size: 15px; font-weight: 700; margin-bottom: 5px; }
.msg-content { font-size: 13.5px; color: var(--ink-2); line-height: 1.6; margin-bottom: 5px; }
.msg-time { font-size: 12px; color: var(--muted); }

/* ---------- 图表容器 ---------- */
.chart-box { position: relative; height: 216px; margin-top: 6px; }
.chart-tabs { display: flex; gap: 7px; margin-bottom: 12px; }
.chart-tab {
  padding: 7px 15px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; font-size: 13.5px; font-weight: 600; color: var(--ink-2);
  cursor: pointer; font-family: var(--font); transition: .15s; min-height: 36px;
}
.chart-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 表单（手机端） ---------- */
.m-field { margin-bottom: 16px; }
.m-field label { display: block; font-size: 14.5px; font-weight: 600; color: var(--ink-2); margin-bottom: 7px; }
.m-input {
  width: 100%; padding: 13px 15px; border: 1.5px solid var(--line);
  border-radius: 11px; font-size: 16px; font-family: var(--font);
  background: #fff; color: var(--ink);
}
.m-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* ---------- 照护对象切换 ---------- */
.patient-pick { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 5px; margin-bottom: 13px; }
.patient-chip {
  padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; font-size: 14px; font-weight: 600; white-space: nowrap;
  cursor: pointer; font-family: var(--font); color: var(--ink-2); transition: .15s;
  display: flex; align-items: center; gap: 6px; min-height: 40px;
}
.patient-chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* =========================================================
   适老模式（大字模式）
   ========================================================= */
body.senior { --m-font-base: 19px; --m-font-sm: 16.5px; --m-touch-min: 56px; }
body.senior .m-title { font-size: 21px; }
body.senior .m-tab-ico { font-size: 25px; }
body.senior .m-tab-txt { font-size: 13.5px; }
body.senior .score-num { font-size: 52px; }
body.senior .metric-item .v { font-size: 30px; }
body.senior .m-li-title { font-size: 19px; }
body.senior .m-li-sub { font-size: 15px; }
body.senior .med-name { font-size: 19px; }
body.senior .med-detail { font-size: 15px; }
body.senior .num-key { height: 64px; font-size: 27px; }
body.senior .result-advice { font-size: 17px; line-height: 1.8; }
body.senior .alert-content { font-size: 16px; }
body.senior .m-quick-btn { padding: 23px 14px; font-size: 19px; }
body.senior .m-quick-btn .ico { font-size: 31px; }
body.senior .m-header { padding-bottom: 4px; }

/* ---------- 响应式（平板/桌面浏览手机版） ---------- */
@media (min-width: 560px) {
  .m-main { max-width: 560px; margin: 0 auto; }
  .m-header-in { max-width: 560px; margin: 0 auto; }
  .m-tabbar { max-width: 560px; left: 50%; transform: translateX(-50%); }
}
