/* =====================================================================
   总检报告系统 · 商业级临床视觉体系
   —— 冷调石板中性 + 深钴蓝主色 + 分层阴影 + 等宽数字 + 克制微交互
   类名与 CSS 变量保持与各页模板 / JS 兼容（仅精修取值、增补 token）。
   ===================================================================== */

:root {
  /* 中性 · 冷调石板（比通用冷灰更有质感、不发脏） */
  --bg: #eef1f7;
  --bg-soft: #f7f9fc;
  --card: #ffffff;
  --ink: #0f1a2e;
  --ink-soft: #263048;
  --muted: #51607a;
  --faint: #8592a6;
  --line: #e6eaf1;
  --line-soft: #eef1f6;
  --line-strong: #cdd5e2;

  /* 主色 · 深钴蓝（可信、克制、临床；比通用亮蓝更沉稳有辨识度） */
  --accent: #2159d8;
  --accent-dark: #1846b3;
  --accent-deep: #0e2c6b;
  --accent-soft: #eaf0fe;
  --accent-softer: #f4f7ff;
  --accent-line: #c4d4fb;
  --accent-glow: rgba(33, 89, 216, .16);

  /* 临床语义色：偏高-红 / 偏低-靛蓝 / 异常-琥珀 / 正常-绿 */
  --high: #d92d20;
  --low: #3a54e0;
  --abn: #c56a0a;
  --normal: #16884a;
  --high-soft: #fdf1f0;
  --low-soft: #eef1fe;
  --abn-soft: #fdf4e7;
  --normal-soft: #ebfaf1;

  /* 圆角阶梯 */
  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;

  /* 分层阴影（冷调偏移，形成真实的高度层级，而非灰扑扑的通用投影） */
  --shadow-xs: 0 1px 2px rgba(15, 26, 46, .06);
  --shadow: 0 1px 2px rgba(15, 26, 46, .04), 0 4px 12px -4px rgba(15, 26, 46, .08);
  --shadow-md: 0 2px 4px rgba(15, 26, 46, .05), 0 12px 28px -10px rgba(15, 26, 46, .16);
  --shadow-lg: 0 24px 56px -16px rgba(15, 26, 46, .28), 0 8px 18px -8px rgba(15, 26, 46, .16);
  --shadow-accent: 0 2px 6px rgba(14, 44, 107, .28), inset 0 1px 0 rgba(255, 255, 255, .18);
  --ring: 0 0 0 3px var(--accent-glow);

  --font-ui: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --font-doc: Georgia, "Songti SC", "STSong", "SimSun", serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
/* 防御性：任何浮层/宽内容都不得撑出横向滚动。对 html 生效不破坏顶栏 sticky。 */
html { overflow-x: hidden; }
body { max-width: 100%; overflow-x: hidden; }
body {
  font-family: var(--font-ui);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  /* 冷调石板底 + 极淡的主色光晕，营造纵深与临床氛围（打印时被覆盖） */
  background:
    radial-gradient(1100px 560px at 100% -8%, rgba(33, 89, 216, .06), transparent 62%),
    radial-gradient(880px 500px at -6% 4%, rgba(33, 89, 216, .045), transparent 58%),
    var(--bg);
  background-attachment: fixed;
}

a, button, input, select, textarea { font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); color: var(--accent-deep); }

/* ---------------- 顶栏（半透明毛玻璃 · 悬浮质感） ---------------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px 12px;
  background: rgba(255, 255, 255, .82);
  backdrop-filter: saturate(1.5) blur(14px);
  -webkit-backdrop-filter: saturate(1.5) blur(14px);
  border-bottom: 1px solid var(--line);
  padding: 9px 24px; min-height: 58px; position: sticky; top: 0; z-index: 50;
  flex-wrap: wrap;
}
.brand a {
  display: inline-flex; align-items: center; gap: 10px;
  font-weight: 650; font-size: 16px; color: var(--ink); text-decoration: none;
  white-space: nowrap; letter-spacing: .005em;
}
.brand .logo-mark { display: block; flex: 0 0 auto; filter: drop-shadow(0 2px 5px var(--accent-glow)); border-radius: 7px; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 14px; border-radius: var(--radius-sm); color: var(--muted);
  text-decoration: none; font-weight: 500; white-space: nowrap; font-size: 14px;
  transition: background .14s ease, color .14s ease, box-shadow .14s ease;
}
.topbar nav a:hover { background: var(--bg-soft); color: var(--ink); }
.topbar nav a.active {
  background: var(--accent-soft); color: var(--accent); font-weight: 600;
  box-shadow: inset 0 0 0 1px var(--accent-line);
}

.user-chip {
  display: inline-flex; align-items: center; gap: 8px; font-size: 13px;
  color: var(--muted); padding-left: 14px; margin-left: 8px;
  border-left: 1px solid var(--line); white-space: nowrap;
}
.user-chip b { color: var(--ink); font-weight: 600; }
.user-chip a { color: var(--faint); text-decoration: none; transition: color .12s; }
.user-chip a:hover { color: var(--high); }

/* ---------------- 登录页（氛围背景 + 悬浮卡片） ---------------- */
.login-wrap {
  min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(1000px 640px at 78% 8%, rgba(33, 89, 216, .16), transparent 55%),
    radial-gradient(760px 620px at 12% 100%, rgba(33, 89, 216, .12), transparent 55%),
    linear-gradient(180deg, #eef2fb 0%, #e6ebf6 100%);
}
.login-card {
  position: relative; width: 392px; max-width: 94vw; background: #fff;
  border: 1px solid #fff; border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  padding: 34px 32px 26px; overflow: hidden;
}
.login-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--accent), #4d84f5 55%, var(--accent-deep));
}
.login-brand {
  display: flex; align-items: center; gap: 11px;
  font-size: 18px; font-weight: 650; margin-bottom: 4px; letter-spacing: .005em;
}
.login-brand svg { filter: drop-shadow(0 3px 8px var(--accent-glow)); border-radius: 8px; }

.container { max-width: 1220px; margin: 26px auto 40px; padding: 0 24px; }
.footer { text-align: center; color: var(--faint); padding: 18px 16px 30px; font-size: 12px; }

/* ---------------- 页头 ---------------- */
.eyebrow {
  font-size: 11.5px; color: var(--accent); margin-bottom: 6px; letter-spacing: .14em;
  text-transform: uppercase; font-weight: 600;
}
h1 { font-size: 23px; font-weight: 680; margin: 0 0 4px; line-height: 1.35; letter-spacing: -.01em; color: var(--ink); }
h2 { font-size: 15px; font-weight: 640; margin: 0 0 12px; letter-spacing: -.005em; }
.subtitle { color: var(--muted); margin: 0 0 20px; max-width: 76ch; }

.card > h2, .card .report-head h2 { color: var(--ink); }

/* ---------------- 卡片 / 布局 ---------------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px;
}
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.home-cols { display: grid; grid-template-columns: 1fr 340px; gap: 16px; align-items: start; }
.home-cols .col { display: grid; gap: 16px; }

/* 状态胶囊（系统在线） */
.status-pill {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--normal-soft); color: var(--normal); border: 1px solid #b7e6c8;
  border-radius: 999px; padding: 5px 14px; font-size: 13px; font-weight: 600;
}
.status-pill::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%; background: #22a35b;
  box-shadow: 0 0 0 3px rgba(34, 163, 91, .18); animation: pill-pulse 2s ease-in-out infinite;
}
@keyframes pill-pulse { 0%, 100% { box-shadow: 0 0 0 3px rgba(34, 163, 91, .18); } 50% { box-shadow: 0 0 0 5px rgba(34, 163, 91, .06); } }

/* ---------------- 统计卡 ---------------- */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 17px 19px; box-shadow: var(--shadow);
  display: flex; flex-direction: column-reverse; justify-content: flex-end;
}
.stat .num {
  font-size: 27px; font-weight: 720; color: var(--ink);
  font-variant-numeric: tabular-nums; line-height: 1.2; letter-spacing: -.02em;
}
.stat .num.sm { font-size: 17px; padding: 4px 0 3px; letter-spacing: 0; }
.stat .label { color: var(--faint); font-size: 13px; font-weight: 500; }
.stat.clickable { cursor: pointer; transition: border-color .16s, box-shadow .16s, transform .12s; user-select: none; }
.stat.clickable:hover { border-color: var(--accent-line); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat.clickable:active { transform: translateY(0); }
.stat.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); background: var(--accent-softer); }

/* 带图标的统计卡（首页） */
.stat-h { flex-direction: row; align-items: center; justify-content: flex-start; gap: 14px; }
.stat-h .stat-body { display: flex; flex-direction: column; min-width: 0; }
.ico {
  width: 46px; height: 46px; border-radius: 12px; flex: 0 0 auto;
  display: grid; place-items: center;
}
.ico svg { width: 22px; height: 22px; }
/* 统一主色瓷片：单色克制、有品牌感，避免多彩模板腔 */
.ico-blue, .ico-green, .ico-amber, .ico-purple {
  background: linear-gradient(160deg, var(--accent-soft), var(--accent-softer));
  color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent-line);
}

/* 快捷入口 */
.entry {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  text-decoration: none; color: inherit; background: #fff;
  transition: border-color .14s, box-shadow .14s, transform .14s;
}
.entry:hover { border-color: var(--accent-line); box-shadow: var(--shadow-md); transform: translateY(-2px); }
.entry:hover .chev { color: var(--accent); transform: translateX(2px); }
.entry .entry-body { min-width: 0; }
.entry .entry-title { font-weight: 640; font-size: 14px; }
.entry .entry-desc { font-size: 12.5px; color: var(--faint); margin-top: 1px; }
.entry .chev { margin-left: auto; color: var(--line-strong); font-size: 16px; flex: 0 0 auto; transition: color .14s, transform .14s; }

/* 键值信息 */
.kv { display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 10px 0; font-size: 13.5px; color: var(--muted); border-bottom: 1px dashed var(--line); }
.kv:last-child { border-bottom: none; }
.kv b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* 使用指引 */
.guide-h { font-size: 13.5px; font-weight: 640; margin: 15px 0 8px; color: var(--ink); }
.guide-h:first-child { margin-top: 0; }
.guide-step { display: flex; gap: 10px; align-items: flex-start; padding: 5px 0; font-size: 13.5px; color: var(--muted); }
.guide-step .n {
  width: 21px; height: 21px; border-radius: 7px; flex: 0 0 auto; margin-top: 2px;
  background: linear-gradient(160deg, var(--accent), var(--accent-dark)); color: #fff;
  font-size: 12px; font-weight: 700; display: grid; place-items: center;
  box-shadow: 0 2px 5px var(--accent-glow); font-variant-numeric: tabular-nums;
}
.check-item { display: flex; gap: 9px; align-items: flex-start; padding: 4px 0; font-size: 13.5px; color: var(--muted); }
.check-item::before { content: '✓'; color: var(--normal); font-weight: 800; flex: 0 0 auto; }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--ink-soft);
  padding: 7px 16px; border-radius: var(--radius-sm); cursor: pointer; font-size: 14px;
  text-decoration: none; font-weight: 550; line-height: 1.5; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: border-color .14s, background .14s, color .14s, box-shadow .14s, transform .12s;
}
.btn:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-softer); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(180deg, #2f66de, var(--accent)); color: #fff;
  border-color: var(--accent-dark); box-shadow: var(--shadow-accent);
}
.btn-primary:hover { background: linear-gradient(180deg, #3a70e6, #2560e2); color: #fff; border-color: var(--accent-dark); box-shadow: 0 6px 16px -4px var(--accent-glow), var(--shadow-accent); }
.btn-primary:active { background: linear-gradient(180deg, var(--accent), var(--accent-dark)); }
.btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; box-shadow: none; }
.btn-sm { padding: 3px 11px; font-size: 13px; }
.btn-danger:hover { border-color: #f0b4ae; color: var(--high); background: var(--high-soft); }

/* ---------------- 表单 ---------------- */
input, select, textarea {
  font-size: 14px; padding: 8px 11px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink);
  transition: border-color .14s, box-shadow .14s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: #b7c1d4; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: var(--ring);
}
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
textarea { width: 100%; resize: vertical; min-height: 64px; line-height: 1.55; }
label { font-size: 13px; color: var(--muted); font-weight: 550; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.toolbar .grow { flex: 1; min-width: 160px; }

.field { margin-bottom: 16px; }
.field label { display: block; margin-bottom: 6px; }
.field .hint { margin-top: 4px; }

/* ---------------- 表格 ---------------- */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
th {
  color: var(--muted); font-weight: 640; font-size: 12px; letter-spacing: .04em;
  background: var(--bg-soft); white-space: nowrap;
  border-bottom: 1px solid var(--line-strong);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--accent-softer); }
tbody tr.row-abn { background: #fdf6ec; }
tbody tr.row-abn:hover { background: #fbefdb; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

.tbl-scroll { overflow: auto; border-radius: var(--radius-sm); }
.tbl-scroll th { position: sticky; top: 0; z-index: 1; }
.tbl-scroll table { min-width: 720px; }
.tbl-x { overflow-x: auto; }
.tbl-x table { min-width: 640px; }

/* ---------------- 徽标 / 标记 ---------------- */
.tag {
  display: inline-block; padding: 1px 9px; border-radius: var(--radius-xs); font-size: 12px;
  background: var(--accent-soft); color: var(--accent); font-weight: 550;
  border: 1px solid var(--accent-line); white-space: nowrap;
}
.tag-gray { background: var(--bg-soft); color: var(--muted); border-color: var(--line-strong); }

.pk-row {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; user-select: none; transition: background .12s, border-color .12s;
}
.pk-row:hover { background: var(--accent-softer); }
.pk-row.active { background: var(--accent-soft); border-color: var(--accent-line); }
.pk-row .grow { flex: 1; min-width: 0; }
.pk-row .btn-sm { flex: 0 0 auto; }

.pkgs { display: flex; gap: 3px; flex-wrap: wrap; }
.pkg {
  display: inline-block; width: 19px; height: 19px; line-height: 17px; text-align: center;
  border-radius: var(--radius-xs); background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-line); font-size: 11px; font-weight: 700;
}

.flag {
  display: inline-block; padding: 2px 9px; border-radius: var(--radius-xs);
  font-size: 12px; font-weight: 600; white-space: nowrap; border: 1px solid transparent;
}
.flag::before {
  content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: currentColor; margin-right: 5px; vertical-align: 1.5px;
}
.flag-high { background: var(--high-soft); color: var(--high); border-color: #f6cdc9; }
.flag-low { background: var(--low-soft); color: var(--low); border-color: #cdd6f8; }
.flag-abnormal { background: var(--abn-soft); color: var(--abn); border-color: #f2d9ab; }
.flag-normal { background: var(--normal-soft); color: var(--normal); border-color: #b7e6c8; }
.flag-unknown { background: var(--bg-soft); color: var(--muted); border-color: var(--line-strong); }
.flag-unknown::before { display: none; }

.badge-missing {
  background: var(--abn-soft); color: var(--abn); border: 1px solid #f2d9ab;
  padding: 1px 9px; border-radius: 999px; font-size: 11px; white-space: nowrap; font-weight: 600;
}

/* ---------------- LLM 配置卡片 ---------------- */
.profile-card {
  border: 1px solid var(--line); border-radius: var(--radius-sm); background: #fff;
  box-shadow: var(--shadow-xs); padding: 14px 16px;
  display: flex; flex-direction: column; gap: 5px; position: relative;
  transition: border-color .14s, box-shadow .14s;
}
.profile-card:hover { box-shadow: var(--shadow); }
.profile-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft), var(--shadow); }
.profile-card .p-name { font-size: 14px; }
.profile-card .p-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ---------------- 文本截断 ---------------- */
.clamp1, .clamp2 { display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; }
.clamp1 { -webkit-line-clamp: 1; }
.clamp2 { -webkit-line-clamp: 2; }
.know { font-size: 12.5px; color: var(--muted); }
.know-advice { font-size: 12px; color: var(--faint); margin-top: 2px; }

/* ---------------- 加载 / 空状态 ---------------- */
.spinner {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--accent-soft); border-top-color: var(--accent);
  animation: spin .7s linear infinite; vertical-align: -3px; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.empty { color: var(--faint); text-align: center; padding: 26px 16px !important; }

/* ---------------- 抽屉 ---------------- */
.drawer-mask {
  position: fixed; inset: 0; background: rgba(15, 26, 46, .42);
  backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none; transition: opacity .22s; z-index: 100;
}
.drawer-mask.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: 480px; max-width: 94vw;
  background: #fff; box-shadow: var(--shadow-lg); z-index: 101;
  transform: translateX(102%); transition: transform .26s cubic-bezier(.32, .72, 0, 1);
  display: flex; flex-direction: column;
}
.drawer.open { transform: translateX(0); }
.drawer.report-drawer { width: 70vw; max-width: 70vw; }
.drawer-head {
  padding: 16px 22px; border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  background: var(--bg-soft);
}
.drawer-body { padding: 22px; overflow-y: auto; flex: 1; }
.drawer-body .field input { width: 100%; }
.drawer-foot {
  padding: 14px 22px; border-top: 1px solid var(--line);
  display: flex; gap: 10px; justify-content: flex-end; background: var(--bg-soft);
}
.close-x {
  cursor: pointer; font-size: 20px; color: var(--muted); border: none; background: none;
  width: 32px; height: 32px; border-radius: var(--radius-sm); line-height: 1;
  transition: background .12s, color .12s;
}
.close-x:hover { background: var(--line-soft); color: var(--ink); }

.hint { font-size: 12px; color: var(--faint); }
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.notice {
  padding: 11px 14px; border-radius: var(--radius-sm); background: var(--abn-soft);
  color: var(--abn); border: 1px solid #f2d9ab; margin-bottom: 16px; font-size: 13px;
}
/* 医生诊断 · 金标准：报告中最权威的结论，醒目高亮 */
.gold-box {
  margin-top: 16px; padding: 13px 16px; border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #fffdf4, #fff9e6); border: 1px solid #f6e2a0;
  border-left: 4px solid #d99413; box-shadow: var(--shadow-xs);
}
.gold-title { font-weight: 700; color: #a4690a; font-size: 14px; margin-bottom: 6px; }
.gold-list { margin: 0; padding-left: 20px; }
.gold-list li { color: #5c3d05; font-size: 14px; line-height: 1.7; }
.diag-inline {
  margin-top: 4px; font-size: 12.5px; color: #a4690a; font-weight: 600;
  background: #fff9e6; border: 1px solid #f6e2a0; border-radius: var(--radius-xs);
  padding: 3px 8px; display: inline-block; white-space: normal; max-width: 560px;
}

/* ---- 四节总检报告（打印页 report_view） ---- */
.find-list { list-style: none; margin: 6px 0 4px; padding: 0; counter-reset: fi; }
.find-item {
  position: relative; padding: 8px 0 8px 26px; line-height: 1.7;
  border-bottom: 1px dashed var(--line, #e5e6eb);
}
.find-item:last-child { border-bottom: none; }
.find-item .dot {
  position: absolute; left: 6px; top: 15px; width: 8px; height: 8px; border-radius: 50%;
  background: var(--abn, #d46b08);
}
.find-item .dot.flag-high, .find-item .dot.flag-low { background: var(--high, #cf1322); }
.find-item .dot.flag-abnormal { background: var(--abn, #d46b08); }
.find-item .dot.flag-normal { background: var(--normal, #389e0d); }
.find-item .find-name { font-weight: 600; color: var(--ink, #1d2129); margin-right: 6px; }
.find-item .find-name::after { content: '：'; color: var(--faint, #86909c); font-weight: 400; }
.find-item .find-detail { color: #4e5969; }

@media print {
  .find-item { break-inside: avoid; }
  .find-item .dot { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .gold-box { background: #fffbe6 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translate(-50%, 8px);
  background: rgba(15, 22, 38, .94); color: #fff; padding: 11px 18px; border-radius: var(--radius-sm);
  z-index: 200; opacity: 0; transition: opacity .22s, transform .22s;
  pointer-events: none; box-shadow: var(--shadow-lg); font-size: 13px; font-weight: 500;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: rgba(197, 34, 25, .96); }

/* ---------------- 标签页（分段控件） ---------------- */
.tabs {
  display: inline-flex; max-width: 100%; overflow-x: auto;
  background: #e7ebf2; border: 1px solid var(--line); border-radius: 10px;
  padding: 3px; gap: 2px; margin: 18px 0 14px;
}
.tab {
  border: none; background: transparent; cursor: pointer;
  padding: 6px 15px; font-size: 13.5px; font-weight: 550; color: var(--muted);
  border-radius: 7px; white-space: nowrap;
  transition: color .14s, background .14s, box-shadow .14s;
}
.tab:hover { color: var(--accent); }
.tab.active {
  color: var(--accent); background: #fff; font-weight: 640;
  box-shadow: 0 1px 3px rgba(15, 26, 46, .14), 0 0 0 1px rgba(15, 26, 46, .02);
}
.tab:disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.tab-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 18px;
  background: #d8dde6; color: var(--muted); text-align: center;
  font-variant-numeric: tabular-nums;
}
.tab-badge.warn { background: var(--high-soft); color: var(--high); }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: panel-in .22s ease; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------------- 报告展示 ---------------- */
.report-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
.summary-box {
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 6px 18px 10px; line-height: 1.7;
}
.summary-box.plain { padding: 16px 18px; white-space: pre-wrap; }
.sum-sys {
  font-weight: 700; color: var(--ink); font-size: 13.5px;
  padding: 14px 0 2px; letter-spacing: .02em;
  display: flex; align-items: center; gap: 8px;
}
.sum-sys::after { content: ''; flex: 1; height: 1px; background: var(--line-strong); }
.sum-sys:first-child { padding-top: 10px; }
.sum-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px dashed var(--line-strong); }
.sum-row:last-child { border-bottom: none; }
.sum-row .flag { flex: 0 0 auto; min-width: 88px; text-align: center; height: fit-content; margin-top: 1px; }
.sum-detail { color: var(--muted); margin-top: 2px; font-size: 13px; }

.text-finding {
  border: 1px solid #f2d9ab; padding: 10px 14px; margin: 10px 0;
  background: var(--abn-soft); border-radius: var(--radius-sm); border-left: 3px solid var(--abn);
}
.text-finding .body { font-size: 13px; white-space: pre-wrap; margin-top: 4px; }
.text-finding.ok { border-color: #b7e6c8; background: var(--normal-soft); border-left-color: var(--normal); }

/* ---------------- 打印报告（正式医学文档） ---------------- */
.doc-org {
  font-size: 11px; letter-spacing: .3em; color: var(--faint); text-transform: uppercase;
  margin-bottom: 6px;
}
.doc-title { font-family: var(--font-doc); font-size: 28px; letter-spacing: .16em; margin: 0; }
.doc-head { border-bottom: 3px double var(--accent-dark); padding-bottom: 16px; }
.doc-abn { font-size: 28px; color: var(--high); font-variant-numeric: tabular-nums; }
.doc-meta {
  display: flex; flex-wrap: wrap; gap: 4px 26px; margin-top: 8px;
  font-size: 12.5px; color: var(--muted);
}
.doc-meta b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
  .home-cols { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 8px 16px; row-gap: 2px; }
  .topbar nav { width: 100%; overflow-x: auto; padding-bottom: 4px; }
  .container { margin: 16px auto; padding: 0 14px; }
  .grid-2 { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .drawer { width: 100vw; max-width: 100vw; }
  .drawer.report-drawer { width: 100vw; max-width: 100vw; }
}
@media (max-width: 480px) {
  .grid-4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat .num { font-size: 22px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation-duration: .01s !important; }
}

/* ---------------- 打印 ---------------- */
@page { margin: 14mm 12mm; }
@media print {
  .topbar, .footer, .no-print, .toast { display: none !important; }
  body { background: #fff !important; font-size: 12px; }
  .container { margin: 0; max-width: none; padding: 0; }
  .card { box-shadow: none; border: none; padding: 0; }
  .summary-box { background: #f6f6f6; border-color: #ddd; }
  .sum-row { border-bottom-color: #ddd; }
  .sum-sys::after { background: #ddd; }
  .tbl-scroll, .tbl-x { max-height: none !important; overflow: visible !important; }
  .tbl-scroll table, .tbl-x table { min-width: 0; }
  tr, .sum-row, .text-finding { break-inside: avoid; }
  h2 { break-after: avoid; }
  a { color: inherit; text-decoration: none; }
}

/* =====================================================================
   报告生成任务队列 · 右侧浮动状态面板（全站可用；服务端执行，关页面不影响）
   ===================================================================== */
.taskq-fab {
  position: fixed; right: 0; top: 50%; transform: translateY(-50%);
  z-index: 900; display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 13px 9px; border: 1px solid var(--accent-line); border-right: none;
  background: #fff; color: var(--accent); cursor: pointer;
  border-radius: 12px 0 0 12px; box-shadow: var(--shadow-lg);
  font-size: 12px; font-weight: 650; letter-spacing: 1px; writing-mode: vertical-rl;
  transition: background .16s, color .16s, right .3s cubic-bezier(.32, .72, 0, 1);
}
.taskq-fab:hover { background: var(--accent-soft); }
.taskq-fab.shifted { right: 428px; }
.taskq-fab .taskq-fab-badge {
  writing-mode: horizontal-tb; min-width: 20px; height: 20px; line-height: 20px;
  padding: 0 6px; border-radius: 10px; background: var(--accent); color: #fff;
  font-size: 12px; font-weight: 700; text-align: center; letter-spacing: 0;
  box-shadow: 0 2px 5px var(--accent-glow);
}
.taskq-fab .taskq-fab-badge.zero { background: var(--line-strong); box-shadow: none; }
.taskq-fab.busy .taskq-fab-badge { animation: taskq-pulse 1.3s ease-in-out infinite; }
@keyframes taskq-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }

.taskq-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: 428px; max-width: 92vw;
  background: var(--bg); border-left: 1px solid var(--line);
  box-shadow: var(--shadow-lg); z-index: 901;
  transform: translateX(100%); transition: transform .3s cubic-bezier(.32, .72, 0, 1);
  display: flex; flex-direction: column;
}
.taskq-drawer.open { transform: translateX(0); }
.taskq-head {
  display: flex; align-items: center; gap: 10px; padding: 15px 16px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.taskq-head h3 { margin: 0; font-size: 15.5px; color: var(--ink); font-weight: 640; }
.taskq-head .taskq-sub { font-size: 12px; color: var(--faint); margin-top: 2px; }
.taskq-head .taskq-x {
  margin-left: auto; border: none; background: var(--line-soft); color: var(--muted);
  width: 30px; height: 30px; border-radius: var(--radius-sm); cursor: pointer; font-size: 17px;
  transition: background .12s, color .12s;
}
.taskq-head .taskq-x:hover { background: #e2e6ee; color: var(--ink); }

.taskq-stats { display: flex; gap: 8px; padding: 11px 14px; background: #fff;
  border-bottom: 1px solid var(--line); }
.taskq-chip {
  flex: 1; text-align: center; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 7px 4px; background: var(--bg-soft);
}
.taskq-chip .n { font-size: 18px; font-weight: 720; color: var(--ink);
  font-variant-numeric: tabular-nums; }
.taskq-chip .l { font-size: 11px; color: var(--faint); }
.taskq-chip.run .n { color: var(--accent); }
.taskq-chip.queue .n { color: var(--abn); }

.taskq-conc {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  background: #fff; border-bottom: 1px solid var(--line);
}
.taskq-conc .l { font-size: 12.5px; color: var(--muted); }
.taskq-conc .l b { color: var(--accent); font-size: 14px; }
.taskq-stepper { margin-left: auto; display: inline-flex; align-items: center; gap: 0;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm); overflow: hidden; }
.taskq-stepper button {
  width: 30px; height: 28px; border: none; background: #fff; cursor: pointer;
  font-size: 16px; color: var(--accent); line-height: 1; transition: background .12s;
}
.taskq-stepper button:hover:not(:disabled) { background: var(--accent-soft); }
.taskq-stepper button:disabled { color: var(--line-strong); cursor: not-allowed; }
.taskq-stepper b { min-width: 34px; text-align: center; font-size: 15px; color: var(--ink);
  border-left: 1px solid var(--line); border-right: 1px solid var(--line);
  line-height: 28px; font-variant-numeric: tabular-nums; }

.taskq-body { flex: 1; overflow-y: auto; padding: 12px 14px 20px; }
.taskq-group-title {
  font-size: 11.5px; font-weight: 700; color: var(--muted); letter-spacing: .06em; text-transform: uppercase;
  margin: 14px 2px 8px; display: flex; align-items: center; gap: 8px;
}
.taskq-group-title:first-child { margin-top: 2px; }
.taskq-group-title .count { color: var(--faint); font-weight: 600; }
.taskq-group-title .clearbtn { margin-left: auto; }

.taskq-item {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: #fff; padding: 11px 12px; margin-bottom: 9px;
  box-shadow: var(--shadow-xs); transition: box-shadow .14s, border-color .14s;
}
.taskq-item:hover { box-shadow: var(--shadow); }
.taskq-item.s-running { background: var(--accent-softer); border-color: var(--accent-line); }
.taskq-item.s-failed  { background: var(--high-soft); }
.taskq-item.s-canceled { opacity: .82; }

.taskq-item-top { display: flex; align-items: center; gap: 8px; }
.taskq-item-title { font-weight: 640; color: var(--ink); font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.taskq-badge {
  font-size: 11px; font-weight: 640; padding: 1px 8px; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap; flex: 0 0 auto;
}
.taskq-badge.s-running { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.taskq-badge.s-queued { background: var(--abn-soft); color: var(--abn); border-color: #f2d9ab; }
.taskq-badge.s-succeeded { background: var(--normal-soft); color: var(--normal); border-color: #b7e6c8; }
.taskq-badge.s-failed { background: var(--high-soft); color: var(--high); border-color: #f6cdc9; }
.taskq-badge.s-canceled { background: var(--bg-soft); color: var(--faint); border-color: var(--line-strong); }

.taskq-item-meta { font-size: 11.5px; color: var(--faint); margin-top: 5px;
  display: flex; flex-wrap: wrap; gap: 4px 10px; }
.taskq-item-meta .mono { font-variant-numeric: tabular-nums; }
.taskq-item-err { font-size: 12px; color: var(--high); margin-top: 5px;
  word-break: break-word; }
.taskq-item-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.taskq-item-actions .btn { padding: 2px 10px; font-size: 12px; }
.taskq-pos { font-size: 11px; color: var(--muted); font-weight: 700;
  background: var(--line-soft); border-radius: var(--radius-xs); padding: 1px 7px; flex: 0 0 auto;
  font-variant-numeric: tabular-nums; }

.taskq-empty { text-align: center; color: var(--faint); font-size: 13px; padding: 30px 10px; }
.taskq-done-note { font-size: 12px; line-height: 1.5; color: var(--muted);
  background: var(--bg-soft); border: 1px dashed var(--line-strong); border-radius: var(--radius-xs);
  padding: 8px 11px; margin: 2px 0 4px; }
.taskq-done-note a { color: var(--accent); font-weight: 600; text-decoration: none; }
.taskq-done-note a:hover { text-decoration: underline; }
.taskq-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  display: inline-block; animation: taskq-pulse 1.1s ease-in-out infinite; flex: 0 0 auto; }

#taskq-page .taskq-item { max-width: 720px; }

@media (max-width: 640px) {
  .taskq-fab.shifted { right: 92vw; }
}

/* =====================================================================
   报告页 · 病人搜索式选择
   ===================================================================== */
.patient-search { position: relative; }
.search-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: #fff; border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); max-height: 300px; overflow-y: auto; padding: 4px;
}
.search-opt {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px;
  border-radius: var(--radius-xs); cursor: pointer; font-size: 13.5px;
}
.search-opt:hover, .search-opt.active { background: var(--accent-soft); }
.search-opt .pid { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.search-opt .g { font-size: 12px; color: var(--muted); }
.search-opt .meta { color: var(--faint); font-size: 12px; margin-left: auto; }
.search-opt.picked { opacity: .5; }
.search-opt.picked::after { content: '已选'; margin-left: auto; font-size: 11px; color: var(--normal); }
.search-note { padding: 8px 10px; color: var(--faint); font-size: 12px; }
.search-empty { padding: 14px; color: var(--faint); font-size: 13px; text-align: center; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 3px 5px 3px 11px;
  border-radius: 14px; background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent-line); font-size: 12.5px; font-weight: 550;
  font-variant-numeric: tabular-nums;
}
.chip button {
  border: none; background: transparent; color: var(--accent); cursor: pointer;
  font-size: 15px; line-height: 1; padding: 0 3px; border-radius: 50%;
}
.chip button:hover { color: var(--high); background: #fff; }
.chips-empty { color: var(--faint); font-size: 13px; }
