/* ==========================================================================
   康复日记 · 偏瘫康复进程记录
   视觉方向：温暖、沉静、有康复关怀感。暖白茶底 + 深墨绿主色 + 珊瑚点缀。
   图表使用 dataviz 标准分类色（与品牌色分离）。
   ========================================================================== */

/* ---------- 设计令牌 ---------- */
:root {
  /* 品牌 */
  --bg: #f6f3ed;              /* 页面平面：暖白 */
  --surface: #ffffff;         /* 卡片 */
  --surface-2: #fbf9f5;       /* 次级面 */
  --brand: #1f6f5c;           /* 深墨绿（主色） */
  --brand-deep: #175345;
  --brand-soft: #e4efe9;      /* 品牌浅底 */
  --brand-softer: #eef5f1;
  --accent: #e0704b;          /* 珊瑚点缀 */
  --accent-soft: #f7e4db;

  /* 文本 */
  --ink: #23302b;             /* 主文本 */
  --ink-2: #5b6a64;           /* 次文本 */
  --ink-3: #8a968f;           /* 弱文本/轴 */
  --line: #e6e1d7;            /* 分隔线 */
  --grid: #e1e0d9;

  /* 状态（dataviz status） */
  --good: #0ca30c;
  --warning: #b07d00;
  --serious: #ec835a;
  --critical: #d03b3b;

  /* 图表（dataviz categorical, light mode） */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #4a3aa7;
  --s8: #e34948;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(31, 60, 50, 0.05), 0 1px 3px rgba(31, 60, 50, 0.04);
  --shadow-md: 0 2px 8px rgba(31, 60, 50, 0.07), 0 6px 20px rgba(31, 60, 50, 0.05);
  --shadow-lg: 0 8px 30px rgba(31, 60, 50, 0.10);

  --radius: 14px;
  --radius-sm: 9px;

  --font: system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

/* ---------- Reset ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.55;
}
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 0.95rem; color: var(--ink); }
.hidden { display: none !important; }

/* 焦点可见性 */
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }

/* ---------- 品牌标记 ---------- */
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px;
  background: linear-gradient(135deg, var(--brand) 0%, #2c8a73 100%);
  color: #fff; flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   登录视图
   ========================================================================== */
.login-view {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(31, 111, 92, 0.10), transparent 60%),
    radial-gradient(800px 400px at -10% 110%, rgba(224, 112, 75, 0.08), transparent 55%),
    var(--bg);
}
.login-card {
  width: 100%; max-width: 400px;
  background: var(--surface);
  border-radius: 20px;
  padding: 40px 36px 28px;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(31, 60, 50, 0.06);
}
.login-brand { text-align: center; margin-bottom: 30px; }
.login-brand .brand-mark { width: 52px; height: 52px; border-radius: 15px; margin-bottom: 16px; }
.login-brand h1 { font-size: 1.7rem; font-weight: 700; letter-spacing: 0.02em; }
.brand-sub { margin: 6px 0 0; color: var(--ink-3); font-size: 0.9rem; }
.login-hint { margin: 20px 0 0; text-align: center; color: var(--ink-3); font-size: 0.82rem; }

/* 登录/注册 Tab */
.auth-tabs {
  display: flex; gap: 4px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 11px; padding: 4px;
  margin-bottom: 22px;
}
.auth-tab {
  flex: 1; border: none; background: transparent;
  padding: 9px 0; border-radius: 8px;
  font-size: 0.92rem; font-weight: 600; color: var(--ink-2);
  transition: all 0.15s;
}
.auth-tab.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }

/* ==========================================================================
   应用布局
   ========================================================================== */
.app-view { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column;
  padding: 22px 14px;
  position: sticky; top: 0; height: 100vh;
}
.side-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 2px 10px 20px;
}
.side-brand .brand-mark { width: 36px; height: 36px; border-radius: 11px; }
.side-title { font-weight: 700; font-size: 1.08rem; letter-spacing: 0.02em; }

.side-nav { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-weight: 500; font-size: 0.94rem;
  transition: background 0.15s, color 0.15s;
}
.nav-item svg { opacity: 0.85; }
.nav-item:hover { background: var(--brand-softer); color: var(--ink); }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.nav-item.active svg { opacity: 1; }

.side-foot { padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
.side-user { display: flex; align-items: center; gap: 10px; padding: 0 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand-deep);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.side-username { font-weight: 600; font-size: 0.9rem; }

.main { flex: 1; padding: 34px 42px 60px; max-width: 1160px; }
@media (max-width: 720px) {
  .sidebar { width: 64px; padding: 18px 8px; }
  .side-brand .side-title, .nav-item span, .side-user .side-username, .side-foot .btn span { display: none; }
  .nav-item { justify-content: center; padding: 11px; }
  .side-foot { align-items: center; }
  .main { padding: 22px 16px 48px; }
}

/* ---------- 页面头 ---------- */
.page-head { margin-bottom: 26px; }
.eyebrow {
  display: inline-block; font-size: 0.74rem; font-weight: 700;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--brand); margin-bottom: 6px;
}
.page-title { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.01em; }
.page-desc { margin: 6px 0 0; color: var(--ink-2); font-size: 0.94rem; max-width: 640px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid rgba(31, 60, 50, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 22px;
}
.card + .card { margin-top: 18px; }
.card-title { font-size: 1.02rem; font-weight: 650; }
.card-sub { color: var(--ink-3); font-size: 0.84rem; margin-top: 2px; }

.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 620px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ---------- 数据项 ---------- */
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.kv-item { padding: 8px 0; border-bottom: 1px solid var(--line); }
.kv-item:last-child { border-bottom: none; }
.kv-label { color: var(--ink-3); font-size: 0.82rem; }
.kv-value { font-weight: 600; font-size: 0.94rem; }
.kv-value.empty { color: var(--ink-3); font-weight: 400; }

/* ---------- 概览 hero：康复阶梯（Brunnstrom 分期） ---------- */
.recovery-card { overflow: hidden; }
.recovery-top { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.big-stage { font-size: 2.6rem; font-weight: 750; color: var(--brand); line-height: 1; }
.big-stage small { font-size: 1rem; font-weight: 600; color: var(--ink-2); margin-left: 4px; }
.stage-track {
  display: flex; gap: 4px; margin-top: 20px;
}
.stage-step {
  flex: 1; height: 26px; border-radius: 6px;
  background: var(--brand-softer);
  position: relative;
  transition: background 0.2s;
}
.stage-step.filled { background: linear-gradient(90deg, var(--brand), #2c8a73); }
.stage-step:first-child { border-radius: 6px 2px 2px 6px; }
.stage-step:last-child { border-radius: 2px 6px 6px 2px; }
.stage-labels { display: flex; gap: 4px; margin-top: 6px; }
.stage-label { flex: 1; text-align: center; font-size: 0.66rem; color: var(--ink-3); }
.stage-label.highlight { color: var(--brand); font-weight: 700; }

/* ---------- 概览 hero：指标条 ---------- */
.vital-row { display: flex; gap: 14px; margin-top: 18px; flex-wrap: wrap; }
.vital {
  flex: 1; min-width: 128px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.vital-label { font-size: 0.78rem; color: var(--ink-3); }
.vital-value { font-size: 1.35rem; font-weight: 700; margin-top: 2px; }
.vital-value .unit { font-size: 0.78rem; font-weight: 500; color: var(--ink-3); margin-left: 2px; }
.vital-value.hi { color: var(--critical); }
.vital-value.warn { color: var(--warning); }
.vital-value.ok { color: var(--brand); }

/* ---------- 统计块 ---------- */
.stat-tile {
  background: var(--surface);
  border: 1px solid rgba(31, 60, 50, 0.06);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 18px 20px;
}
.stat-value { font-size: 1.9rem; font-weight: 750; line-height: 1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--ink-2); font-size: 0.84rem; margin-top: 6px; }
.stat-note { color: var(--ink-3); font-size: 0.78rem; margin-top: 4px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1px solid transparent; border-radius: 10px;
  padding: 10px 18px; font-size: 0.92rem; font-weight: 600;
  transition: background 0.15s, border-color 0.15s, transform 0.05s, box-shadow 0.15s;
  background: var(--surface-2); color: var(--ink);
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--brand-deep); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #c95f3d; }
.btn-outline { background: transparent; border-color: var(--brand); color: var(--brand); }
.btn-outline:hover { background: var(--brand-soft); }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn-danger { background: transparent; color: var(--critical); border-color: rgba(208, 59, 59, 0.3); }
.btn-danger:hover { background: #fbeeee; }
.btn-sm { padding: 7px 12px; font-size: 0.84rem; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 16px; }
.field-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.field-hint { font-size: 0.76rem; color: var(--ink-3); margin-top: 4px; }
input[type="text"], input[type="password"], input[type="date"], input[type="number"],
select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px;
  padding: 9px 12px; background: var(--surface); transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 92, 0.13);
}
textarea { resize: vertical; min-height: 78px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 14px; }
@media (max-width: 620px) { .form-row, .form-row-3 { grid-template-columns: 1fr; } }
.form-error {
  background: #fbeeee; color: var(--critical);
  border: 1px solid rgba(208, 59, 59, 0.25);
  border-radius: 8px; padding: 9px 12px; font-size: 0.84rem; margin-bottom: 14px;
}

/* 分段单选（chips） */
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.chip span {
  display: inline-block; padding: 7px 13px; border-radius: 20px;
  border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); font-size: 0.85rem; cursor: pointer;
  transition: all 0.15s; user-select: none;
}
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* 短信验证码行（输入框 + 发送按钮并排） */
.sms-row { display: flex; gap: 8px; }
.sms-row input { flex: 1; }
.sms-send-btn { flex-shrink: 0; white-space: nowrap; }

/* 评分行（0-10 数字选择） */
.rate { display: flex; gap: 5px; flex-wrap: wrap; }
.rate-btn {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 0.82rem; font-weight: 600; color: var(--ink-2);
  transition: all 0.12s;
}
.rate-btn:hover { border-color: var(--brand); color: var(--brand); }
.rate-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- 记录卡片列表 ---------- */
.record-list { display: flex; flex-direction: column; gap: 12px; }
.record-item {
  display: flex; align-items: center; gap: 16px;
  background: var(--surface); border: 1px solid rgba(31, 60, 50, 0.06);
  border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s, border-color 0.15s;
}
.record-item:hover { box-shadow: var(--shadow-md); }
.record-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 58px; padding: 6px 10px; border-radius: 10px;
  background: var(--brand-soft); color: var(--brand-deep);
}
.record-date .d { font-size: 1.25rem; font-weight: 750; line-height: 1; }
.record-date .m { font-size: 0.68rem; font-weight: 600; }
.record-main { flex: 1; min-width: 0; }
.record-summary { font-weight: 600; font-size: 0.94rem; }
.record-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag {
  font-size: 0.72rem; font-weight: 600; padding: 2px 8px; border-radius: 12px;
  background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line);
}
.tag.bp { background: #e8f0fb; color: #1c5cab; border-color: transparent; }
.tag.pain { background: #f7e4db; color: #a84a24; border-color: transparent; }
.tag.stage { background: var(--brand-soft); color: var(--brand-deep); border-color: transparent; }
.record-actions { display: flex; gap: 6px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--ink-3); font-size: 0.78rem; font-weight: 650; letter-spacing: 0.03em; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- 图表 ---------- */
.viz { width: 100%; }
.viz-wrap { background: #fcfcfb; border: 1px solid var(--grid); border-radius: var(--radius-sm); padding: 14px; }
.viz-title { font-size: 0.92rem; font-weight: 650; margin-bottom: 4px; }
.viz-sub { font-size: 0.78rem; color: var(--ink-3); margin-bottom: 12px; }
.legend { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--ink-2); }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; }
.viz-empty {
  padding: 40px 16px; text-align: center; color: var(--ink-3); font-size: 0.9rem;
}

/* 迷你趋势（概览页 sparkline 区块） */
.mini-chart { margin-top: 14px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 11px 20px; border-radius: 10px;
  font-size: 0.9rem; box-shadow: var(--shadow-lg); z-index: 100;
  animation: toast-in 0.22s ease;
  max-width: 90vw;
}
.toast.err { background: var(--critical); }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 空状态 ---------- */
.empty-state { text-align: center; padding: 48px 20px; color: var(--ink-3); }
.empty-state svg { opacity: 0.5; margin-bottom: 12px; }
.empty-state .empty-title { font-size: 1.02rem; font-weight: 650; color: var(--ink-2); margin-bottom: 4px; }
.empty-state .empty-desc { font-size: 0.88rem; margin-bottom: 16px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar .filter-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.filter-group select, .filter-group input[type="date"] { width: auto; }

/* ---------- 弹层（Modal） ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(23, 45, 38, 0.42);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 16px; z-index: 90; overflow-y: auto;
  animation: fade-in 0.18s ease;
}
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 720px;
  box-shadow: var(--shadow-lg); padding: 26px 28px;
  animation: pop-in 0.2s ease;
}
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-title { font-size: 1.15rem; font-weight: 700; }
.modal-close {
  border: none; background: var(--surface-2); width: 34px; height: 34px;
  border-radius: 50%; font-size: 1.1rem; color: var(--ink-2); display: flex; align-items: center; justify-content: center;
}
.modal-close:hover { background: var(--brand-soft); color: var(--ink); }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(8px) scale(0.99); } to { opacity: 1; transform: none; } }

/* 训练条目（动态增删） */
.training-block { border: 1px solid var(--line); border-radius: 11px; padding: 14px; margin-bottom: 12px; background: var(--surface-2); }
.training-block-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.training-block-head .t-num { font-size: 0.8rem; font-weight: 700; color: var(--brand); letter-spacing: 0.04em; }
.remove-t {
  border: none; background: transparent; color: var(--critical);
  font-size: 0.82rem; font-weight: 600; padding: 4px 8px; border-radius: 7px;
}
.remove-t:hover { background: #fbeeee; }

/* 分区标题（表单内） */
.form-section {
  font-size: 0.82rem; font-weight: 700; color: var(--brand);
  letter-spacing: 0.05em; text-transform: uppercase;
  margin: 22px 0 4px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}

/* ---------- 响应式细节 ---------- */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
