/* ==========================================================================
 * 替尔泊肽体重追踪 —— 样式
 * 版式参考 hrt.52duck.cn：左侧栏导航 + 独立设置页 + 列表式设置行
 * ========================================================================== */

:root {
  --bg: #ffffff;
  --ink: #1a1916;
  --muted: #6b6860;
  --faint: #9b978e;
  --surface: #edecea;
  --surface-2: #f6f5f3;
  --line: #e3e1dc;
  --accent: #1d6fd6;
  --accent-2: #0e4f9e;
  /* 主色照抄 hrt.52duck.cn 的 --color-m3-primary：陶土橘，只用在
     主按钮底 / 行内文字按钮 / 选中态 / 开关打开态。图表曲线继续用 --accent 蓝。 */
  --primary: #cc785c;
  --primary-light: #d8927c;
  --primary-container: #fceee8;
  --on-primary-container: #7a3920;
  --teal: #0f766e;
  --danger: #c0392b;
  --ok: #14875a;
  --r-sm: 10px;
  --r-md: 12px;
  --r: 12px;
  --r-lg: 16px;
  --sidebar-w: 260px;
}
body[data-theme="dark"] {
  color-scheme: dark;
  --bg: #17191d; --ink: #f2f3f4; --muted: #b8bdc3; --faint: #929aa3;
  --surface: #34383f; --surface-2: #24282e; --line: #424850;
  --primary: #d88b72; --primary-light: #e8a58e; --primary-container: #403027;
  --on-primary-container: #f5c9b7; --accent: #8fc2ff; --accent-2: #b8d7ff;
}
body[data-theme="blue"] {
  --bg: #fcfdfe; --ink: #24333c; --muted: #5d6d77; --faint: #83929b;
  --surface: #ffffff; --surface-2: #f3f8fb; --line: #dce8ef;
  --primary: #548eae; --primary-light: #78abc6; --primary-container: #e6f4fb;
  --on-primary-container: #245371; --accent: #6aaace; --accent-2: #3d80a8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.6 ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1, h2 { margin: 0; font-weight: 600; }
h1 { font-size: 20px; letter-spacing: -.2px; }
h2 { font-size: 15px; }
b { font-weight: 500; }
p { margin: 0; }

/* ---------------------------------------------------------- 布局 --- */
.app { display: flex; min-height: 100vh; align-items: stretch; }

.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  border-right: 1px solid var(--line);
  padding: 22px 13px 14px;
  display: flex; flex-direction: column; gap: 4px;
  position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 9px 20px; }
.brand-mark { color: var(--ink); display: inline-flex; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text b { font-size: 15px; font-weight: 600; }
.brand-text i { font-style: normal; font-size: 11.5px; color: var(--faint); }

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav button {
  display: flex; align-items: center; gap: 13px;
  width: 100%; padding: 9px 13px; border: 0; border-radius: var(--r);
  background: transparent; color: var(--muted); font-size: 15px; font-family: inherit;
  cursor: pointer; text-align: left; transition: background .12s, color .12s;
}
.nav button:hover { background: var(--surface-2); color: var(--ink); }
.nav button.on { background: var(--surface-2); color: var(--ink); font-weight: 500; }
.nav button svg { flex: 0 0 auto; opacity: .85; }
.nav-account-icon { display: none; }

.sidebar-foot { margin-top: auto; padding: 10px 13px 0; font-size: 11.5px; color: var(--faint); }

.main { flex: 1 1 auto; min-width: 0; padding: 30px 34px 56px; }
/* 内容列宽对齐参考站的 max-w-2xl（672px），比原来的 1120px 窄一大截 */
.page { max-width: 760px; margin: 0 auto; }
.setting-section { padding: 15px 0 22px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.setting-section h2 { margin-bottom: 12px; }
.calibration-details { padding: 12px 0 4px; border-top: 1px solid var(--line); }
.calibration-details summary, .calibration-section > summary { cursor: pointer; font-size: 14px; font-weight: 500; }
.calibration-details .note { margin: 12px 0; line-height: 1.6; overflow-wrap: anywhere; }
.calibration-section > summary { padding: 6px 0; }
.calibration-section-body { padding: 14px 0 0; }
.calibration-section-body > .note { margin: 12px 0; line-height: 1.6; }
.settings-subhead { display: flex; align-items: center; gap: 10px; padding: 4px 0 15px; }
.settings-subhead h2 { font-size: 18px; }
.tabpane .card { border: 0; border-bottom: 1px solid var(--line); border-radius: 0; padding: 15px 0 22px; }
/* 页头吸顶（参考站是 sticky top-0 + 右上角行内按钮） */
.page-head {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 0 12px; margin-bottom: 10px;
}
.page-head > div { min-width: 0; }
.page-sub { margin-top: 4px; font-size: 14px; color: var(--muted); }

/* ---------------------------------------------------------- 卡片 --- */
.card {
  background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 18px 20px; margin-bottom: 14px;
}
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.spacer { flex: 1 1 auto; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.two-col .card { margin-bottom: 14px; }

/* -------------------------------------------------------- 指标卡 --- */
.overview-details { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 18px 0 14px; }
.overview-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 15px 2px; cursor: pointer; list-style: none;
}
.overview-summary::-webkit-details-marker { display: none; }
.overview-summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.overview-summary-copy { display: flex; flex-direction: column; min-width: 0; }
.overview-summary-title { font-size: 16px; font-weight: 600; }
.overview-summary .page-sub { display: block; font-size: 12px; line-height: 1.45; }
.overview-chevron { flex: 0 0 auto; color: var(--muted); transition: transform .15s ease; }
.overview-details[open] .overview-chevron { transform: rotate(180deg); }
.overview-details .stats { margin-top: 4px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 6px 18px; margin-bottom: 14px; }
.stat { padding: 10px 0; }
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 22px; font-weight: 600; letter-spacing: -.5px; margin-top: 1px; }
.stat .value small { font-size: 12px; font-weight: 500; color: var(--faint); margin-left: 3px; }
.stat .delta { font-size: 11.5px; color: var(--faint); margin-top: 1px; }
.down { color: var(--ok); } .up { color: var(--danger); } .muted { color: var(--faint); }

/* ---------------------------------------------------------- 图表 --- */
.chart-wrap {
  position: relative; height: 400px; touch-action: pan-y;
  /* 参考站也这么做：拖动手势不能被浏览器的"选中文字"抢走 */
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.live-strip { padding: 10px 0 17px; border-bottom: 1px solid var(--line); margin-bottom: 15px; }
.live-head, .heatmap-head { display: flex; align-items: center; gap: 8px; }
.live-head .head-btn { margin-left: auto; }
.live-values { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 8px; }
.live-values > div { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px; min-width: 0; }
.live-values span { flex-basis: 100%; font-size: 12px; color: var(--muted); }
.live-values strong { font-size: 29px; font-weight: 400; font-variant-numeric: tabular-nums; line-height: 1.15; }
.live-values small { color: var(--faint); font-size: 12px; }
.heatmap-section { border-bottom: 1px solid var(--line); padding: 8px 0 18px; margin-bottom: 16px; }
.heatmap-head .note { margin-left: auto; }
.record-heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 12px); grid-auto-columns: 12px; gap: 3px; overflow-x: auto; padding: 12px 0; }
.hm-cell, .heatmap-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--surface); }
.hm-cell { border: 0; padding: 0; cursor: pointer; }
.hm-cell:hover, .hm-cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.heatmap-tooltip {
  position: fixed; z-index: 45; display: flex; flex-direction: column; gap: 3px;
  width: max-content; max-width: calc(100vw - 16px); min-width: 172px;
  padding: 9px 11px; border-radius: 6px; background: #20242a; color: #fff;
  font-size: 12px; line-height: 1.45; pointer-events: none;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}
.heatmap-tooltip b { font-weight: 600; margin-bottom: 2px; }
.heatmap-tooltip .hm-alert { color: #ffd1ba; }
.hm-weight { background: #64a6cf !important; }
.hm-inj { background: #e4a169 !important; }
.hm-both { background: #3b987f !important; }
.hm-missing { background: var(--surface) !important; }
.hm-due { outline: 2px solid var(--danger); outline-offset: -1px; }
.heatmap-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 11px; color: var(--muted); }
.heatmap-legend span { display: inline-flex; align-items: center; gap: 4px; }
.compare-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; margin-top: 10px; }
.compare-grid > div { display: flex; flex-direction: column; gap: 3px; border-top: 2px solid var(--line); padding-top: 9px; }
.compare-grid strong { font-size: 23px; font-weight: 500; }
.compare-grid small { color: var(--faint); }
.lab-list { margin-top: 8px; }
#chart { width: 100%; height: 100%; display: block; }
.chart-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 16px; margin: 2px 0 0 58px; color: var(--muted); font-size: 12px; }
.chart-legend span { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.chart-legend i { display: inline-block; width: 18px; height: 0; border-top: 3px solid currentColor; }
.chart-legend i.dashed { border-top-style: dashed; }
.chart-legend i.band { height: 8px; border: 0; background: rgba(194,112,92,.32); }
.chart-note { margin: 8px 0 0 58px; color: var(--faint); font-size: 11px; line-height: 1.5; }
.chart-metric-row { display: flex; align-items: center; justify-content: flex-start; margin: -3px 0 8px; }
.chart-metric-row .seg { flex: 0 0 auto; }
.inline-num input {
  width: 64px; padding: 4px 8px; border: 1px solid var(--line); border-radius: var(--r-sm);
  font-size: 13px; font-family: inherit; color: var(--ink); background: var(--bg);
}
.inline-num { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); margin: 0; }
.inline-num input { margin: 0; }

.tooltip {
  position: absolute; pointer-events: none; z-index: 5;
  background: rgba(26, 25, 22, .94); color: #fff; border-radius: var(--r-sm);
  padding: 8px 11px; font-size: 12px; line-height: 1.55; min-width: 132px;
  max-width: calc(100% - 12px); transform: translate(-50%, -100%);
  box-shadow: 0 6px 18px rgba(26, 25, 22, .16);
}
.tooltip .tt-title { font-weight: 600; margin-bottom: 3px; }
.tooltip .tt-row { display: flex; gap: 10px; justify-content: space-between; }
.tooltip .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }
.tooltip .tt-note { margin-top: 4px; padding-top: 4px; border-top: 1px solid rgba(255,255,255,.18); font-size: 11px; color: rgba(255,255,255,.72); }
/* 可平移时用光标提示，不再占画面写一行字 */
.chart-wrap.pannable { cursor: grab; }
.cell-edit {
  width: 72px; padding: 3px 6px; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}
.chart-wrap.panning { cursor: grabbing; }

/* -------------------------------------------------------- 表单 --- */
label { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 11px; }
input, select {
  display: block; width: 100%; margin-top: 5px; padding: 8px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  font-size: 14px; color: var(--ink); background: var(--bg); font-family: inherit;
}
/* 参考站的 focus 只换边框颜色，不加 ring / outline */
input:focus, select:focus { outline: none; border-color: var(--primary); }
input[hidden] { display: none !important; }
textarea {
  display: block; width: 100%; margin-top: 5px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--r-md);
  font: 13px/1.7 ui-monospace, SFMono-Regular, Menlo, Consolas, "PingFang SC", monospace;
  color: var(--ink); background: var(--surface-2); resize: vertical; min-height: 132px;
}
textarea:focus { outline: none; border-color: var(--primary); background: var(--bg); }
/* 参考站在 ≤768px 用 !important 把输入框字号顶到 16px，防 iOS 聚焦时整页放大。
   日期类输入不参与（iOS 上会顶破布局）。 */
@media (max-width: 768px) {
  input:not([type="date"]):not([type="datetime-local"]):not([type="checkbox"]),
  select, textarea { font-size: 16px !important; }
}
.paste-preview { margin-top: 12px; font-size: 13px; color: var(--muted); line-height: 1.7; }
.paste-preview .ok { color: var(--ok); font-weight: 500; }
.paste-preview .warn { color: var(--danger); }
.paste-preview ul { margin: 6px 0 0; padding-left: 18px; }
.paste-preview li { margin: 2px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid2 .span2 { grid-column: 1 / -1; }
.grid2.tight { gap: 0 12px; }
.grid2.tight label { margin-bottom: 8px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: end; }
.row .btn { margin-bottom: 11px; height: 36px; }
.note { font-size: 12px; color: var(--faint); margin: 4px 0 0; line-height: 1.55; }
.disclaimer { font-size: 12px; color: var(--faint); margin: 4px 0 0; }

/* -------------------------------------------------------- 按钮 --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--r-md); border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font-size: 14px; font-weight: 500;
  font-family: inherit; cursor: pointer; white-space: nowrap; transition: .13s;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn.danger { color: var(--danger); border-color: #edcdc8; }
.btn.danger:hover { background: #fdf2f0; }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger.solid:disabled { opacity: .4; cursor: not-allowed; }
.btn.full { width: 100%; margin-top: 6px; }
.mini {
  font-size: 12px; padding: 4px 10px; border-radius: var(--r-md);
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
  font-family: inherit; cursor: pointer;
}
.mini:hover { background: var(--surface-2); color: var(--ink); }
/* 页头 / 卡头的行内文字按钮（参考站 28px 高、无边框、hover 才铺底） */
.head-btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 0; border-radius: var(--r-md); background: transparent;
  color: var(--primary); font: 500 14px/1.4 inherit; cursor: pointer;
}
.head-btn:hover { background: var(--surface); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; }
.seg button {
  border: 0; border-right: 1px solid var(--line); background: var(--bg); color: var(--muted);
  padding: 8px 12px; font-size: 13px; font-family: inherit; cursor: pointer; white-space: nowrap;
}
.seg button:last-child { border-right: 0; }
.seg button.on { background: var(--primary-container); color: var(--on-primary-container); font-weight: 600; }

.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; margin: 0; }
.chk input { width: auto; margin: 0; }

/* 设置分区导航：照抄参考站移动端的「图标底座 + 标题 + 描述 + chevron」入口列表 */
.chips { display: flex; flex-direction: column; margin-bottom: 18px; }
.chips button {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 0; border: 0; border-bottom: 1px solid var(--line);
  border-radius: 0; background: transparent; color: var(--ink);
  font-size: 15px; font-family: inherit; text-align: left; cursor: pointer; transition: .13s;
}
.chips button:hover { background: var(--surface-2); }
.chips button:last-child { border-bottom: 0; }
.chips button.on { font-weight: 600; }
.chips button.on .tile { background: var(--primary-container); color: var(--on-primary-container); }
.tile {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: var(--r-lg);
  background: var(--surface); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}

/* ---------------------------------------------------- 设置行 --- */
.srow {
  display: flex; align-items: center; gap: 16px;
  width: 100%; padding: 18px 0; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; text-align: left; font-family: inherit; color: var(--ink);
  font-size: 15px;
}
.srow:last-child { border-bottom: 0; padding-bottom: 2px; }
.srow-label { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.srow-label b { font-weight: 500; }
.srow-label i { font-style: normal; font-size: 12px; color: var(--faint); }
.srow-btn { cursor: pointer; transition: background .12s; }
.srow-btn:hover { background: var(--surface-2); }
.srow-btn.danger .srow-label b { color: var(--danger); }
.chev { color: var(--faint); font-size: 19px; line-height: 1; }
.srow .seg { flex: 0 0 auto; }

.switch { position: relative; display: inline-block; width: 44px; height: 24px; margin: 0; flex: 0 0 auto; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch span {
  position: absolute; inset: 0; background: var(--surface); border-radius: 999px; transition: .18s;
}
.switch span::after {
  content: ""; position: absolute; left: 4px; top: 4px; width: 16px; height: 16px;
  background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .18s;
}
.switch input:checked + span { background: var(--primary); }
.switch input:checked + span::after { transform: translateX(20px); }

.notice {
  display: block;
  border: 1px solid #f0dcc0; background: #fdf6ec; color: #7a5410;
  border-radius: var(--r-sm); padding: 9px 12px; margin-bottom: 14px; font-size: 12px; line-height: 1.5;
}
.notice b { font-weight: 600; }
.notice .notice-item { position: relative; padding-right: 28px; }
.notice .notice-item + .notice-item { margin-top: 8px; padding-top: 8px; border-top: 1px solid #f0dcc0; }
.notice-item details summary { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; list-style: none; cursor: pointer; }
.notice-item details summary::-webkit-details-marker { display: none; }
.notice-item details summary > span:first-child { min-width: 0; }
.notice-more { flex: 0 0 auto; font-size: 11px; text-decoration: underline; }
.notice-body { margin-top: 7px; padding-top: 7px; border-top: 1px solid #f0dcc0; }
.notice-x {
  position: absolute; top: -2px; right: -4px; width: 24px; height: 24px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 7px; background: transparent; color: #a9803a;
  font: 15px/1 inherit; cursor: pointer;
}
.notice-x:hover { background: rgba(122, 84, 16, .1); color: #7a5410; }

.stats-note { margin: -6px 0 16px; font-size: 11.5px; color: var(--faint); }

.badge {
  font-size: 11.5px; color: var(--muted); background: var(--surface);
  border-radius: 999px; padding: 3px 10px; white-space: nowrap;
}
.badge.on { background: #e6f0fb; color: var(--accent-2); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 7px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); margin: 0; }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }

/* -------------------------------------------------------- 表格 --- */
.table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; background: var(--surface-2); font-weight: 500; font-size: 12px; color: var(--muted); z-index: 1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--surface-2); }
td.num { font-variant-numeric: tabular-nums; }
.del { border: 0; background: transparent; color: var(--faint); cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 7px; border-radius: 6px; }
.del:hover { color: var(--danger); background: #fdf2f0; }

/* 记录页：按天分组的无卡片时间线。 */
.records-head { padding-top: 6px; padding-bottom: 14px; }
.records-head .page-sub { margin-top: 2px; }
.records-actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.records-actions .head-btn { white-space: nowrap; }
.records-actions .head-btn.active { color: var(--ink); }
.records-actions #btn-new-record svg { transition: transform .15s; }
.records-actions #btn-new-record[aria-expanded="true"] svg { transform: rotate(45deg); }
.record-entry { padding: 14px 0 20px; margin-bottom: 14px; border-bottom: 1px solid var(--line); }
.record-entry-head { padding-bottom: 10px; }
.record-entry > .seg { display: inline-flex; margin-bottom: 16px; }
.record-form { max-width: 580px; }
.record-form label:not(.record-batch-toggle) { margin-top: 16px; }
.record-form input:not([type="checkbox"]) { min-height: 44px; }
.record-section-title { padding: 12px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; font-weight: 600; }
.record-batch-toggle { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 0; padding: 10px 0; cursor: pointer; }
.record-batch-toggle b { display: block; font-size: 14px; color: var(--ink); }
.record-batch-toggle small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 400; }
.record-batch-toggle input { appearance: none; flex: 0 0 44px; width: 44px; height: 24px; margin: 0; padding: 0; border: 0; border-radius: 999px; background: var(--line); cursor: pointer; }
.record-batch-toggle input::before { content: ""; display: block; width: 16px; height: 16px; margin: 4px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0002; transition: transform .15s; }
.record-batch-toggle input:checked { background: var(--primary); }
.record-batch-toggle input:checked::before { transform: translateX(20px); }
.record-batch-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.record-form-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.record-form-actions .btn { min-width: 88px; }
.record-form-actions .btn:only-child { margin-left: auto; }
.record-selection-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0 14px; color: var(--muted); font-size: 13px; }
.danger-text { color: var(--danger); }
.danger-text:disabled { opacity: .4; cursor: not-allowed; }
.timeline-list { padding-bottom: 16px; }
.timeline-day { margin: 0 0 12px; }
.timeline-day-head {
  position: sticky; top: 64px; z-index: 3; display: flex; align-items: baseline; gap: 8px;
  padding: 12px 0 8px; background: var(--bg); color: var(--muted);
}
.timeline-day-head b { font-size: 12px; font-weight: 600; }
.timeline-day-head span { font-size: 12px; color: var(--faint); }
.timeline-item {
  display: flex; align-items: flex-start; gap: 12px; min-height: 62px;
  padding: 14px 8px; border-bottom: 1px solid var(--line); transition: background .12s;
}
.timeline-item:hover { background: var(--surface-2); }
.timeline-dot { flex: 0 0 auto; width: 6px; height: 6px; margin-top: 8px; border-radius: 50%; background: var(--faint); }
.timeline-dot.weight { background: var(--teal); }
.timeline-select { flex: 0 0 18px; width: 18px; height: 18px; margin: 1px 0 0 -5px; padding: 0; border: 1px solid var(--faint); border-radius: 50%; background: var(--bg); color: #fff; font-size: 12px; line-height: 16px; cursor: pointer; }
.timeline-select.on { background: var(--primary); border-color: var(--primary); }
.timeline-main { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
.timeline-title { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.timeline-title b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; font-weight: 500; }
.timeline-plan { flex: 0 0 auto; margin-left: auto; padding: 1px 5px; border-radius: 4px; background: var(--surface); color: var(--muted); font-size: 11px; }
.timeline-title time { flex: 0 0 auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.timeline-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; color: var(--muted); font-size: 12px; }
.timeline-meta > span { opacity: .45; }
.timeline-meta strong { color: var(--ink); font-weight: 500; cursor: pointer; }
.timeline-item .del { flex: 0 0 auto; margin: 0 -7px 0 1px; opacity: 0; }
.timeline-item:hover .del, .timeline-item .del:focus-visible { opacity: 1; }
.timeline-empty { padding: 80px 24px; text-align: center; color: var(--muted); font-size: 14px; }
.records-extra { border-top: 1px solid var(--line); padding: 10px 0 18px; }
.records-extra summary { display: block; padding: 6px 0; list-style: none; cursor: pointer; color: var(--muted); font-size: 13px; font-weight: 500; }
.records-extra summary::-webkit-details-marker { display: none; }
.records-extra summary::after { content: "⌄"; float: right; font-size: 18px; line-height: 1; }
.records-extra[open] summary::after { transform: rotate(180deg); }
.records-export-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
.records-extra .card-head { margin-top: 16px; }
.records-extra .table-wrap { margin-top: 10px; }

/* ------------------------------------------------------ 弹窗 --- */
dialog { border: 0; border-radius: var(--r-lg); padding: 0; max-width: 470px; width: calc(100% - 32px); box-shadow: 0 24px 60px -20px rgba(26,25,22,.4); }
dialog::backdrop { background: rgba(26,25,22,.32); }
.dialog-body { padding: 22px; }
.dialog-body h2 { font-size: 17px; margin-bottom: 8px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.secret-value { display: block; margin-top: 12px; padding: 10px; word-break: break-all; user-select: all; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm); }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: rgba(26,25,22,.94); color: #fff; padding: 10px 17px; border-radius: var(--r);
  font-size: 13px; z-index: 50;
}

/* ------------------------------------------------------ 响应式 --- */
@media (max-width: 767px) {
  .app { flex-direction: column; }
  .sidebar {
    width: auto; flex: 0 0 auto; height: auto;
    position: sticky; top: 0; z-index: 10; background: var(--bg);
    border-right: 0; border-bottom: 1px solid var(--line);
    padding: 12px 16px; gap: 0;
  }
  .brand { padding: 0; }
  .sidebar-foot { display: none; }

  /* Mobile navigation follows the five equal-width tabs of the reference. */
  .nav {
    position: fixed; left: 16px; right: 16px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 40;
    flex-direction: row; align-items: stretch; gap: 4px;
    height: 65px; padding: 6px; border: 1px solid var(--line); border-radius: 16px;
    background: var(--bg);
    box-shadow: 0 2px 8px rgba(0, 0, 0, .08);
  }
  .nav button {
    flex: 1 1 0; width: auto; min-width: 0;
    flex-direction: column; justify-content: center; gap: 4px;
    padding: 6px 0; border-radius: 0;
    font-size: 10px; line-height: 15px; font-weight: 500; text-align: center;
  }
  .nav button:hover { background: transparent; color: var(--ink); }
  .nav button.on { background: transparent; color: var(--ink); font-weight: 500; }
  .nav button svg { width: 20px; height: 20px; opacity: 1; }
  .nav-avatar { display: none; }
  .nav-account-icon { display: block; }
  #nav-admin { display: none; }

  .main { padding: 20px 16px 104px; }
  /* 顶部品牌条是 sticky 的，页头要停在它下面，否则标题会被盖住 */
  .page-head { top: 58px; }
  .records-head { flex-wrap: wrap; }
  .timeline-day-head { top: 124px; }
  .timeline-item .del { opacity: 1; }
  .two-col { grid-template-columns: 1fr; }
  .chart-wrap { height: 330px; }
  .chart-legend, .chart-note { margin-left: 8px; }
  h1 { font-size: 20px; }
  /* 胶囊占了下缘，提示条往上挪，别被盖住 */
  .toast { bottom: 96px; }
}
@media (max-width: 560px) {
  .timeline-day-head { top: 174px; }
  .grid2 { grid-template-columns: 1fr; }
  .grid2 .span2 { grid-column: auto; }
  .stat .value { font-size: 19px; }
  .srow { flex-direction: column; align-items: flex-start; gap: 8px; }
  .srow .seg { align-self: flex-start; }
  #page-settings .srow { flex-direction: row; align-items: center; gap: 10px; }
  #page-settings .srow .seg { align-self: auto; }
  #page-settings .srow .srow-label { min-width: 0; }
  #page-settings .srow .chev { margin-left: auto; flex: 0 0 auto; }
  #page-settings .srow .switch { margin-left: auto; }
  .live-values strong { font-size: 24px; }
  .heatmap-head { align-items: flex-start; flex-direction: column; gap: 0; }
  .heatmap-head .note { margin: 0; }
}
@media (max-width: 420px) {
  .chart-card { padding-left: 12px; padding-right: 12px; }
}

/* ================================================ 账户 / 登录 / 管理 --- */
.auth {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 28px 16px; background: var(--surface-2);
}
.auth-card {
  width: 100%; max-width: 400px; background: var(--bg); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 26px 24px 20px;
  box-shadow: 0 18px 50px -26px rgba(26, 25, 22, .3);
}
.auth-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 20px; }
.auth-card h1 { font-size: 20px; margin-bottom: 16px; }
.auth-err {
  margin: 2px 0 10px; font-size: 12.5px; color: var(--danger);
  background: #fdf2f0; border: 1px solid #f3d9d4; border-radius: var(--r-sm);
  padding: 8px 11px; line-height: 1.5;
}
.auth-skip {
  display: block; width: 100%; margin-top: 14px; padding: 6px; border: 0;
  background: transparent; color: var(--faint); font: 12.5px/1.5 inherit;
  cursor: pointer; text-decoration: underline;
}
.auth-skip:hover { color: var(--ink); }

/* 侧栏「账户」入口：图标就是当前账号的头像，尺寸对齐其它 18px 图标 */
.nav-avatar {
  width: 18px; height: 18px; font-size: 10px; font-weight: 600;
  background: var(--surface); color: var(--muted);
}
.nav button.on .nav-avatar { background: var(--ink); color: #fff; }
.nav-avatar img { display: block; width: 100%; height: 100%; object-fit: cover; }
.nav-avatar-plain { background: transparent; color: inherit; }

.avatar {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%;
  background: var(--ink); color: #fff; display: inline-flex; align-items: center;
  justify-content: center; font-size: 12.5px; font-weight: 600; overflow: hidden;
}
.avatar.lg { width: 54px; height: 54px; font-size: 21px; }
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

.acct-head {
  display: flex; align-items: center; gap: 14px; padding: 4px 0 14px;
  border-bottom: 1px solid var(--line); margin-bottom: 2px; flex-wrap: wrap;
}
.acct-id { display: flex; flex-direction: column; gap: 2px; margin-right: auto; min-width: 0; }
.acct-id b { font-size: 16px; font-weight: 600; }
.acct-id i { font-style: normal; font-size: 12.5px; color: var(--faint); }
.mono { font: 12.5px/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: var(--muted); }

.session-list { display: flex; flex-direction: column; }
.session-row {
  display: flex; align-items: center; gap: 14px; padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.session-row:last-child { border-bottom: 0; padding-bottom: 2px; }
.session-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.session-main b { font-weight: 500; font-size: 14px; display: flex; align-items: center; gap: 8px; }
.session-main i { font-style: normal; font-size: 12px; color: var(--faint); }

.badge.ok { background: #e6f4ee; color: var(--ok); }
.badge.warn { background: #fdeceb; color: var(--danger); }
.mini.danger { color: var(--danger); border-color: #edcdc8; }
.mini.danger:hover { background: #fdf2f0; color: var(--danger); }
.row-actions { display: flex; gap: 6px; }

.tfa-setup { display: flex; gap: 16px; align-items: flex-start; margin: 12px 0 14px; flex-wrap: wrap; }
.tfa-qr {
  flex: 0 0 auto; width: 176px; height: 176px; padding: 6px; background: #fff;
  border: 1px solid var(--line); border-radius: var(--r);
  display: flex; align-items: center; justify-content: center;
}
.tfa-qr svg { display: block; width: 100%; height: 100%; }
.tfa-key { display: flex; flex-direction: column; gap: 6px; min-width: 0; flex: 1 1 160px; }
.tfa-key code {
  font: 13px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--r-sm); padding: 8px 10px; word-break: break-all;
}
.tfa-key .mini { align-self: flex-start; }

@media (max-width: 767px) {
  #sync-hint { display: none; }
}
@media (max-width: 560px) {
  .acct-id { margin-right: 0; width: 100%; }
  .tfa-qr { width: 150px; height: 150px; }
  .row-actions { flex-wrap: wrap; }
}

/* ====================================== 账户子页面（照参考站版式） --- */
.ico { flex: 0 0 auto; color: var(--muted); }
.srow .ico { margin-right: 2px; }

.sub-head { display: flex; align-items: center; gap: 12px; margin: 0 0 14px; }
.sub-head h2 { font-size: 18px; }
.sub-head i { display: block; margin-top: 2px; font-style: normal; font-size: 12.5px; color: var(--faint); }
.sub-back {
  flex: 0 0 auto; width: 32px; height: 32px; border: 1px solid var(--line);
  border-radius: var(--r-sm); background: var(--bg); color: var(--muted);
  font: 15px/1 inherit; cursor: pointer;
}
.sub-back:hover { background: var(--surface-2); color: var(--ink); }

.acct-top {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 6px 0 18px; border-bottom: 1px solid var(--line); margin-bottom: 4px;
}
.acct-avatar {
  position: relative; width: 112px; height: 112px; padding: 0; border: 0;
  border-radius: 50%; overflow: hidden; background: var(--surface);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
}
.acct-avatar-hover {
  position: absolute; inset: 0; z-index: 2; opacity: 0; transition: .15s;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: rgba(26, 25, 22, 0); color: #fff; font-size: 12px;
}
.acct-avatar:hover .acct-avatar-hover { background: rgba(26, 25, 22, .35); opacity: 1; }
.acct-avatar-hover em { font-style: normal; font-weight: 500; }
.acct-name-row { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
.acct-name-row b { font-size: 18px; font-weight: 600; }
.acct-crown { color: var(--accent); font-size: 14px; }
.acct-handle { font-style: normal; font-size: 12.5px; color: var(--faint); }

.avatar.xl { width: 112px; height: 112px; font-size: 36px; font-weight: 300; background: var(--surface); color: var(--muted); }
.acct-avatar .avatar.xl { border-radius: 0; }

.linkbtn {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 4px;
  border: 0; border-radius: 6px; background: transparent; color: var(--accent);
  font: 12.5px/1.5 inherit; cursor: pointer;
}
.linkbtn:hover { background: var(--surface-2); }
.linkbtn.wide { width: 100%; justify-content: center; padding: 12px; color: var(--muted); font-size: 13.5px; }
.linkbtn.wide:hover { color: var(--danger); }
.linkbtn[disabled] { opacity: .4; cursor: not-allowed; }

.sec-title { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.sec-title.danger { color: var(--danger); }
.srow-trail { flex: 0 0 auto; font-size: 12px; color: var(--faint); }

.acct-foot { display: flex; justify-content: center; padding: 6px 0 2px; }
.acct-foot .linkbtn { color: var(--muted); font-size: 13.5px; }
.acct-foot .linkbtn:hover { color: var(--ink); }

.row2 { display: flex; gap: 10px; }
.row2 .btn { flex: 1 1 0; justify-content: center; }

.tfa-steps { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.tfa-steps span { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--faint); }
.tfa-steps span i {
  width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; font-size: 11px; font-style: normal;
}
.tfa-steps span.on { color: var(--ink); }
.tfa-steps span.on i { border-color: var(--ink); background: var(--surface-2); }
.tfa-steps span.done i { border-color: var(--ink); color: var(--ok); }
.tfa-steps u { flex: 1 1 auto; height: 1px; background: var(--line); }

.tfa-state { display: flex; align-items: flex-start; gap: 12px; padding: 2px 0 14px; }
.tfa-state .ico { margin-top: 1px; }
.tfa-state.danger .ico { color: var(--danger); }
.tfa-state p { font-size: 13.5px; }
.tfa-state p.note { font-size: 12px; }

.tfa-qr { width: 176px; height: 176px; margin: 4px auto 14px; }
.tfa-key-row {
  display: flex; align-items: center; gap: 8px; margin: 6px 0 12px; padding: 8px 10px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.tfa-key-row code {
  flex: 1 1 auto; padding: 0; border: 0; background: transparent; word-break: break-all;
  font: 12.5px/1.6 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.tfa-key-row code.blur { filter: blur(4px); user-select: none; }
.iconbtn {
  flex: 0 0 auto; display: inline-flex; padding: 4px; border: 0; border-radius: 6px;
  background: transparent; color: var(--muted); cursor: pointer;
}
.iconbtn:hover { background: var(--surface); color: var(--ink); }

.otp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px; letter-spacing: .6em; text-align: center; padding-left: .6em;
}

.session-title { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.chip-now { font-size: 11px; font-weight: 500; color: var(--muted); background: var(--surface); border-radius: 6px; padding: 1px 6px; }
.session-row .ico { margin-top: 2px; }
