/* =========================================================
   慢病管理系统 - 共享样式（三端通用）
   轻科技风设计系统：蓝紫渐变 / 大圆角 / 毛玻璃 / 柔和阴影
   ========================================================= */
:root {
  /* 品牌主色（蓝紫渐变，参考小米/华为健康轻科技风） */
  --brand: #4f6ef7;
  --brand-2: #6d8bff;
  --brand-3: #8a63ff;
  --brand-dark: #3a54d6;
  --brand-light: #eef1ff;
  --brand-grad: linear-gradient(135deg, #4f6ef7 0%, #8a63ff 100%);
  --brand-grad-soft: linear-gradient(135deg, #6d8bff 0%, #9b7bff 100%);

  --ok: #10b981;
  --ok-bg: #d1fae5;
  --warn: #f59e0b;
  --warn-bg: #fef3c7;
  --danger: #f43f5e;
  --danger-bg: #ffe4e6;
  --info: #0ea5e9;
  --info-bg: #e0f2fe;

  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #94a3b8;
  --line: #eef0f5;
  --bg: #f5f6fb;
  --card: #ffffff;
  --glass: rgba(255, 255, 255, .72);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 24px;
  --shadow: 0 2px 12px rgba(79, 90, 140, .06), 0 1px 3px rgba(79, 90, 140, .04);
  --shadow-md: 0 6px 22px rgba(79, 90, 140, .1);
  --shadow-lg: 0 16px 44px rgba(79, 90, 140, .16);
  --shadow-brand: 0 10px 28px rgba(99, 102, 241, .32);
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 20px; border-radius: 12px; border: none;
  font-size: 15px; font-weight: 600; cursor: pointer;
  font-family: var(--font); transition: .18s cubic-bezier(.2,.8,.3,1); white-space: nowrap;
}
.btn:active { transform: scale(.975); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary { background: var(--brand-grad); color: #fff; width: 100%; box-shadow: var(--shadow-brand); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.05); box-shadow: 0 12px 32px rgba(99,102,241,.4); }
.btn-ghost { background: #fff; color: var(--ink-2); border: 1.5px solid var(--line); }
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 7px 14px; font-size: 13.5px; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 26px; font-size: 16.5px; border-radius: 14px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 18px; }
.field label {
  display: block; font-size: 14px; font-weight: 600;
  color: var(--ink-2); margin-bottom: 7px;
}
.field label .req { color: var(--danger); margin-left: 2px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--line);
  border-radius: 10px; font-size: 15.5px; font-family: var(--font);
  color: var(--ink); background: #fff; transition: .16s;
}
.input:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(99, 102, 241, .12);
}
.input::placeholder { color: #94a3b8; }
textarea.input { resize: vertical; min-height: 92px; line-height: 1.65; }
select.input { appearance: none; background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; line-height: 1.5; }

/* 复选/单选 */
.check { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; font-size: 14px; }
.check input { width: 19px; height: 19px; margin-top: 2px; accent-color: var(--brand); flex-shrink: 0; cursor: pointer; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px; margin-bottom: 16px;
  border: 1px solid rgba(255,255,255,.6);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; padding-bottom: 13px; border-bottom: 1px solid var(--line);
}
.card-title { font-size: 16.5px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-title .dot-mark { width: 4px; height: 17px; border-radius: 2px; background: var(--brand); }

/* ---------- 标签 ---------- */
.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600; line-height: 1.5;
}
.tag-ok { background: var(--ok-bg); color: #065f46; }
.tag-warn { background: var(--warn-bg); color: #92400e; }
.tag-danger { background: var(--danger-bg); color: #991b1b; }
.tag-info { background: var(--brand-light); color: var(--brand-dark); }
.tag-muted { background: #f1f5f9; color: var(--muted); }

/* ---------- 提示条 ---------- */
.alert-box {
  display: flex; gap: 11px; padding: 13px 16px;
  border-radius: 11px; font-size: 13.8px; line-height: 1.6;
  margin-bottom: 14px;
}
.alert-box.ok { background: var(--ok-bg); color: #065f46; }
.alert-box.warn { background: var(--warn-bg); color: #92400e; }
.alert-box.danger { background: var(--danger-bg); color: #991b1b; }
.alert-box.info { background: var(--brand-light); color: var(--brand-dark); }
.alert-box .ico { flex-shrink: 0; font-size: 16px; line-height: 1.4; }

/* ---------- 空态 ---------- */
.empty { text-align: center; padding: 52px 20px; color: var(--muted); }
.empty .ico { font-size: 42px; margin-bottom: 12px; opacity: .45; }
.empty p { font-size: 14.5px; }

/* ---------- 加载 ---------- */
.cc-spin {
  display: inline-block; width: 15px; height: 15px;
  border: 2px solid rgba(255, 255, 255, .35);
  border-top-color: #fff; border-radius: 50%;
  animation: cc-spin .7s linear infinite; vertical-align: -2px; margin-right: 5px;
}
.cc-spin-dark { border-color: rgba(99, 102, 241, .25); border-top-color: var(--brand); }
@keyframes cc-spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, #eef0f5 25%, #e2e5ee 37%, #eef0f5 63%);
  background-size: 400% 100%; animation: sk 1.3s ease infinite;
  border-radius: 10px; height: 15px; margin-bottom: 10px;
}
@keyframes sk { 0% { background-position: 100% 50%; } 100% { background-position: 0 50%; } }

/* ---------- Toast ---------- */
.cc-toast-box {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 9px;
  align-items: center; pointer-events: none; width: max-content; max-width: 92vw;
}
.cc-toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 11px;
  background: #fff; box-shadow: var(--shadow-lg);
  font-size: 14.5px; font-weight: 500; transition: .25s;
  border-left: 4px solid var(--brand); max-width: 92vw;
  animation: toast-in .25s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(-12px); } }
.cc-toast-ico {
  width: 20px; height: 20px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff;
}
.cc-toast-success { border-left-color: var(--ok); }
.cc-toast-success .cc-toast-ico { background: var(--ok); }
.cc-toast-error { border-left-color: var(--danger); }
.cc-toast-error .cc-toast-ico { background: var(--danger); }
.cc-toast-warn { border-left-color: var(--warn); }
.cc-toast-warn .cc-toast-ico { background: var(--warn); }
.cc-toast-info { border-left-color: var(--brand); }
.cc-toast-info .cc-toast-ico { background: var(--brand); }

/* ---------- 弹窗 ---------- */
.cc-modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .5);
  z-index: 9000; display: flex; align-items: center; justify-content: center;
  padding: 20px; animation: fade-in .18s ease; backdrop-filter: blur(2px);
}
@keyframes fade-in { from { opacity: 0; } }
.cc-modal {
  background: #fff; border-radius: 16px; width: 100%; max-width: 460px;
  max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg);
  animation: modal-in .22s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes modal-in { from { opacity: 0; transform: translateY(16px) scale(.97); } }
.cc-modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.cc-modal-head h3 { font-size: 17px; font-weight: 700; }
.cc-modal-close {
  background: none; border: none; font-size: 24px; color: var(--muted);
  cursor: pointer; line-height: 1; padding: 0 4px; font-family: var(--font);
}
.cc-modal-body { padding: 22px; }
.cc-modal-foot {
  padding: 16px 22px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end;
}

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tbl th {
  text-align: left; padding: 11px 13px; font-weight: 600;
  color: var(--ink-2); background: #f8fafc; font-size: 13.5px;
  border-bottom: 1.5px solid var(--line); white-space: nowrap;
}
table.tbl td {
  padding: 12px 13px; border-bottom: 1px solid #f1f5f9;
  color: var(--ink-2); vertical-align: middle;
}
table.tbl tbody tr:hover { background: #f8fafc; }
table.tbl tbody tr:last-child td { border-bottom: none; }

/* ---------- 分页 ---------- */
.pager { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 18px 0; }
.pager button {
  min-width: 36px; height: 36px; padding: 0 11px; border-radius: 8px;
  border: 1.5px solid var(--line); background: #fff; cursor: pointer;
  font-size: 14px; font-family: var(--font); color: var(--ink-2); transition: .15s;
}
.pager button:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }
.pager button.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pager button:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- 数值显示 ---------- */
.metric { display: flex; align-items: baseline; gap: 5px; }
.metric .num { font-size: 30px; font-weight: 800; letter-spacing: -.5px; line-height: 1.1; }
.metric .unit { font-size: 13px; color: var(--muted); font-weight: 500; }
.metric.sm .num { font-size: 22px; }
.metric.lg .num { font-size: 40px; }

/* ---------- 进度条 ---------- */
.bar { height: 8px; border-radius: 5px; background: #eef0f5; overflow: hidden; }
.bar > span {
  display: block; height: 100%; border-radius: 5px;
  background: var(--brand-grad); transition: width .5s ease;
}
.bar.ok > span { background: linear-gradient(90deg, #10b981, #34d399); }
.bar.warn > span { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.bar.danger > span { background: linear-gradient(90deg, #f43f5e, #fb7185); }

/* ---------- 布局辅助 ---------- */
.row { display: flex; gap: 12px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.row-center { display: flex; align-items: center; gap: 10px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 20px; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; } .mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; } .mb-3 { margin-bottom: 24px; }
.text-muted { color: var(--muted); } .text-sm { font-size: 13px; }
.text-center { text-align: center; } .text-right { text-align: right; }
.fw-6 { font-weight: 600; } .fw-7 { font-weight: 700; }
.text-ok { color: var(--ok); } .text-warn { color: var(--warn); }
.text-danger { color: var(--danger); } .text-brand { color: var(--brand); }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* 免责声明 */
.disclaimer {
  font-size: 12.5px; color: var(--muted); line-height: 1.65;
  background: #f8fafc; border-left: 3px solid #cbd5e1;
  padding: 11px 14px; border-radius: 0 8px 8px 0; margin-top: 12px;
}

/* =========================================================
   新增功能组件（AI / 任务 / 成就 / 目标 / 排行榜 / 咨询）
   ========================================================= */

/* 分段切换（Segment） */
.seg { display: flex; background: #eef0f5; border-radius: 12px; padding: 4px; gap: 4px; }
.seg > button {
  flex: 1; padding: 9px 6px; border: none; background: transparent;
  border-radius: 9px; font-size: 14px; font-weight: 600; color: var(--muted);
  cursor: pointer; font-family: var(--font); transition: .18s;
}
.seg > button.active { background: #fff; color: var(--brand); box-shadow: 0 2px 8px rgba(79,90,140,.12); }

/* 毛玻璃悬浮操作条 */
.glass-bar {
  position: sticky; bottom: calc(var(--m-tabbar-h, 62px) + 12px);
  background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,.6); border-radius: 16px;
  padding: 12px; display: flex; gap: 10px; box-shadow: var(--shadow-md);
}

/* AI 对话 */
.chat-list { display: flex; flex-direction: column; gap: 14px; }
.chat-row { display: flex; gap: 10px; }
.chat-row.user { flex-direction: row-reverse; }
.chat-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 17px; color: #fff;
  background: var(--brand-grad); box-shadow: var(--shadow-brand);
}
.chat-row.user .chat-avatar { background: #eef1ff; color: var(--brand); box-shadow: none; }
.chat-bubble {
  max-width: 78%; padding: 12px 15px; border-radius: 16px;
  font-size: 15px; line-height: 1.65; word-break: break-word;
}
.chat-row.assistant .chat-bubble { background: #fff; box-shadow: var(--shadow); border-top-left-radius: 5px; }
.chat-row.user .chat-bubble {
  background: var(--brand-grad); color: #fff; border-top-right-radius: 5px;
}
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3 { font-size: 15px; margin: 8px 0 5px; }
.chat-bubble p { margin: 5px 0; }
.chat-bubble ul, .chat-bubble ol { margin: 6px 0 6px 18px; }
.chat-bubble li { margin: 3px 0; }
.chat-bubble strong { font-weight: 700; }
.chat-bubble em { color: inherit; opacity: .85; font-size: 12.5px; }
.chat-bubble hr { border: none; border-top: 1px solid #eef0f5; margin: 10px 0; }

/* 快捷提问 chip */
.quick-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.quick-chip {
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; font-size: 13.5px; font-weight: 500; color: var(--ink-2);
  cursor: pointer; font-family: var(--font); transition: .15s;
}
.quick-chip:hover, .quick-chip:active { border-color: var(--brand); color: var(--brand); background: var(--brand-light); }

/* 任务卡片 */
.task-item { display: flex; align-items: center; gap: 13px; padding: 15px 16px; border-bottom: 1px solid #f4f5f9; }
.task-item:last-child { border-bottom: none; }
.task-ico {
  width: 42px; height: 42px; border-radius: 13px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 20px; background: #f4f5fb;
}
.task-ico.done { background: var(--brand-grad); }
.task-body { flex: 1; min-width: 0; }
.task-title { font-size: 15px; font-weight: 650; margin-bottom: 2px; }
.task-desc { font-size: 12.5px; color: var(--muted); }
.task-check {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid #d5dae4; display: grid; place-items: center;
  font-size: 15px; color: transparent; transition: .18s; cursor: pointer;
}
.task-check.done { background: var(--brand-grad); border-color: transparent; color: #fff; }

/* 成就徽章 */
.ach-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ach-item { text-align: center; cursor: default; }
.ach-badge {
  width: 62px; height: 62px; margin: 0 auto 8px; border-radius: 20px;
  display: grid; place-items: center; font-size: 30px;
  background: #f4f5fb; filter: grayscale(1); opacity: .45; transition: .25s;
  position: relative;
}
.ach-item.unlocked .ach-badge {
  background: linear-gradient(135deg, #eef1ff, #f4efff);
  filter: none; opacity: 1; box-shadow: 0 6px 16px rgba(99,102,241,.2);
}
.ach-item .ach-name { font-size: 12px; font-weight: 600; color: var(--ink-2); line-height: 1.3; }
.ach-item .ach-progress { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* 排行榜 */
.rank-item { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid #f4f5f9; }
.rank-item:last-child { border-bottom: none; }
.rank-no {
  width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 14px; font-weight: 800;
  color: var(--muted); background: #f4f5fb;
}
.rank-item.top1 .rank-no { background: linear-gradient(135deg,#fbbf24,#f59e0b); color: #fff; }
.rank-item.top2 .rank-no { background: linear-gradient(135deg,#cbd5e1,#94a3b8); color: #fff; }
.rank-item.top3 .rank-no { background: linear-gradient(135deg,#fbbf24,#d97706); color: #fff; }
.rank-avatar {
  width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center; font-size: 17px; font-weight: 700; color: #fff;
  background: var(--brand-grad-soft);
}
.rank-body { flex: 1; min-width: 0; }
.rank-name { font-size: 15px; font-weight: 650; }
.rank-name .me { font-size: 11px; color: var(--brand); margin-left: 5px; }
.rank-sub { font-size: 12px; color: var(--muted); }
.rank-score { font-size: 17px; font-weight: 800; color: var(--brand); }

/* 目标进度 */
.goal-item { padding: 16px; border-bottom: 1px solid #f4f5f9; }
.goal-item:last-child { border-bottom: none; }
.goal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.goal-name { font-size: 15px; font-weight: 650; }
.goal-val { font-size: 13px; color: var(--muted); }
.goal-val b { color: var(--brand); font-size: 15px; }

/* 数值胶囊 */
.stat-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px;
  border-radius: 999px; background: #f4f5fb; font-size: 13px; font-weight: 600; color: var(--ink-2);
}

/* 设备卡 */
.device-item { display: flex; align-items: center; gap: 13px; padding: 15px 16px; border-bottom: 1px solid #f4f5f9; }
.device-item:last-child { border-bottom: none; }
.device-ico {
  width: 44px; height: 44px; border-radius: 14px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 22px; background: #f4f5fb;
}
.device-dot { width: 8px; height: 8px; border-radius: 50%; background: #cbd5e1; display: inline-block; }
.device-dot.online { background: #10b981; box-shadow: 0 0 0 3px rgba(16,185,129,.15); }

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .grid-2.mobile-2 { grid-template-columns: repeat(2, 1fr); }
}

/* =========================================================
   v3 新增组件：群组 / 宣教 / 消息 / 分享 / 提醒
   ========================================================= */

/* 分类筛选 chips */
.cat-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 500;
  background: #f4f5fb; color: var(--ink-2); cursor: pointer;
  transition: all .18s ease; border: 1px solid transparent;
}
.chip.active {
  background: var(--brand-light); color: var(--brand-dark);
  border-color: var(--brand); font-weight: 600;
}

/* 搜索行 */
.search-row { display: flex; gap: 8px; }
.search-row .m-input { flex: 1; }

/* 家庭群组卡片 */
.group-card { cursor: pointer; transition: transform .18s ease, box-shadow .18s ease; }
.group-card:active { transform: scale(.985); }
.group-notice {
  margin-top: 10px; padding: 9px 12px; border-radius: 10px;
  background: var(--brand-light); color: var(--brand-dark); font-size: 13px;
}

/* 家庭动态 */
.feed-item {
  padding: 13px 0; border-bottom: 1px solid #f4f5f9;
}
.feed-item:last-child { border-bottom: none; }

/* 用药提醒 */
.reminder-item {
  padding: 15px 0; border-bottom: 1px solid #f4f5f9;
}
.reminder-item:last-child { border-bottom: none; }

/* 开关 */
.switch { position: relative; display: inline-block; width: 46px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
  position: absolute; inset: 0; border-radius: 999px; background: #cbd5e1;
  transition: .25s; cursor: pointer;
}
.switch .slider::before {
  content: ''; position: absolute; width: 20px; height: 20px; border-radius: 50%;
  left: 3px; top: 3px; background: #fff; transition: .25s; box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.switch input:checked + .slider { background: var(--brand-grad); }
.switch input:checked + .slider::before { transform: translateX(20px); }

/* 文章操作按钮 */
.article-actions { display: flex; gap: 8px; align-items: center; }

/* 群组卡片 hover */
.group-card:hover { box-shadow: var(--shadow-md); }
