.privacy-section { padding: 12px; }
.privacy-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; max-width: 920px; margin: 0 auto; display: grid; gap: 10px; }
.privacy-title { font-weight: 900; font-size: 18px; }
.privacy-h { font-weight: 800; }
.support-section { padding: 12px; }
.support-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; max-width: 920px; margin: 0 auto; }
.support-title { font-weight: 900; margin-bottom: 8px; }

.pubs-section { padding: 12px; }
.pubs-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; max-width: 920px; margin: 0 auto; display: grid; gap: 12px; }
.pubs-title { font-weight: 900; font-size: 18px; }
.pubs-authors { color: #374151; }
.pubs-affil { color: #6b7280; font-size: 14px; }
.pubs-h { font-weight: 800; margin-top: 6px; }

/* Standalone pages (Support/Publications) scrollable area under appbar */
.standalone-page { position: fixed; top: 56px; left: 0; right: 0; bottom: 0; overflow: auto; -webkit-overflow-scrolling: touch; background: var(--bg); padding: 12px 0; z-index: 1; }
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-ink: #ffffff;
  --accent: #06b6d4;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --vl: #4cb689;
  --l: #3aa3a2;
  --ml: #3c79c6;
  --mh: #a78bfa;
  --h: #f59e0b;
  --vh: #ef4444;
  --sidebar-w: 400px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  color: var(--text);
  background: var(--bg);
  overflow: hidden; /* 页面不滚动，仅右侧内容滚动 */
}

.appbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 40;
}

.appbar .icon-button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.menu-label {
  margin-left: 8px;
  font-weight: 600;
  cursor: pointer;
}

.appbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.appbar-title .logo {
  width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  color: var(--accent);
}

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: calc(100vh - 56px); /* 固定高度以启用右侧独立滚动 */
}

.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  padding: 0 0 16px 0; /* 顶部无内边距，面板顶栏贴边 */
  display: flex;
  flex-direction: column;
  gap: 0;
}

.side-sections { overflow: visible; }

.side-panel { background: #fff; border-radius: 0; margin-bottom: 0; overflow: hidden; }
.side-panel-header { padding: 18px 20px; font-weight: 800; letter-spacing: .03em; border-bottom: 1px solid var(--border); font-size: 22px; display: flex; align-items: center; gap: 12px; }

/* Clinical Data form layout */
.cd-form { padding: 24px 24px 28px 24px; display: grid; gap: 28px; background: #f7f9fb; }
.row { display: grid; grid-template-columns: 1.25fr 1fr .9fr; align-items: center; gap: 16px; }
.row-input { justify-self: end ; width: 140px; position: relative; left: 100px; display: flex; justify-content: center; }
.row + .row { margin-top: 4px; }
.row-label { font-weight: 800; font-size: 13px; line-height: 1.35; }
.row-label .small { font-weight: 600; color: var(--muted); display: block; margin-top: 6px; }
.row-input input, .row-input select { width: 100%; height: 52px; border: 2px solid #cbd5e1; border-radius: 10px; padding: 0 12px; background: #fff; font-size: 16px; text-align: center; text-align-last: center; }
.row-input input:focus, .row-input select:focus { outline: none; border-color: #94a3b8; box-shadow: 0 0 0 3px rgba(148,163,184,.2); }
.row-hint { color: #111827; font-weight: 800; text-align: right; font-size: 18px; }
.req { color: #ef4444; margin-right: 4px; }
.link { color: #2563eb; text-decoration: underline; }
.sep { opacity: .5; margin: 0 6px; }
.section-divider { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; color: #111827; font-weight: 900; letter-spacing: .03em; margin: 6px 0; }
.section-divider::before, .section-divider::after { content: ""; height: 1px; background: var(--border); }
.section-divider > span { padding: 8px 0; }

.btn-lg { height: 44px; font-size: 16px; }

/* Score box */
.score-box { margin-top: 8px; padding: 12px 16px; background: #ffffff; border: 1px dashed #cbd5e1; border-radius: 10px; display: grid; gap: 6px; }
.score-title { font-weight: 800; color: #111827; }
.score-value { font-weight: 900; font-size: 24px; }
.score-details { color: #6b7280; font-size: 12px; }

.field {
  display: grid;
  gap: 6px;
}

.field input, .field select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
}

.side-actions {
  margin-top: auto;
  display: grid;
  gap: 12px;
  padding: 16px;
}

.side-actions-inline { display: grid; grid-template-columns: 1fr 1fr; align-items: center; gap: 12px; }
.side-actions-inline .switch { justify-self: start; }
.side-actions-inline .btn { justify-self: end; }

.btn {
  height: 48px;
  padding: 0 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary {
  background: #0b5aa7; /* 深蓝 */
  color: #fff;
  border-color: #0b5aa7;
}

.btn-ghost {
  background: transparent;
}

.btn-outline {
  background: #fff;
  border: 2px solid #cbd5e1;
}

.btn .icon { font-size: 18px; }
.icon-blue { color: #0b5aa7; }

.switch {
  display: grid;
  grid-template-columns: auto 44px; /* 文本在左，滑块在右 */
  align-items: center;
  column-gap: 12px;
  color: var(--muted);
}
.switch .switch-label { grid-column: 1; grid-row: 1; white-space: nowrap; }
.switch .slider { grid-column: 2; grid-row: 1; justify-self: end; }

.switch input { display: none; }

.switch .slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: #e5e7eb;
  border-radius: 999px;
}

.switch .slider::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: transform .2s ease;
}

.switch input:checked + .slider {
  background: var(--accent);
}

.switch input:checked + .slider::after {
  transform: translateX(20px);
}

.switch .switch-label { font-size: 12px; }

.content {
  padding: 16px 20px 32px 20px;
  display: grid;
  gap: 16px;
  overflow: auto; /* 仅右侧区域滚动 */
}

/* Stats cards */
.stats { display: grid; grid-template-columns: .7fr 1.3fr; gap: 12px; }
.stat.survival { justify-self: stretch; }
.stat:first-child { justify-self: stretch; }
.stat { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px; display: grid; gap: 8px; }
.stat-title { color: #6b7280; font-weight: 800; }
.stat-row { display: flex; align-items: center; gap: 12px; }
.stat-value { font-size: 44px; font-weight: 900; letter-spacing: .02em; }
.badge { font-weight: 900; padding: 6px 12px; border-radius: 8px; color: #fff; letter-spacing: .04em; }
.badge-red { background: #b23a3a; }
.badge-orange { background: #d8822c; }
.badge-slate { background: #475569; }
.badge-green { background: #1B9E77; }

/* Survival stat */
.stat-row-large { gap: 10px; }
.stat-unit { font-size: 28px; font-weight: 900; }
.stat-tag { background: #f3f4f6; color: #111827; border-radius: 8px; padding: 4px 8px; font-weight: 800; }
.stat-sub { color: #6b7280; }

.pill {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: 600;
  margin-right: 8px;
}

.pill-success { background: rgba(16,185,129,.15); color: var(--success); }
.pill-warning { background: rgba(245,158,11,.15); color: var(--warning); }

.tabs {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
}

/* New header with title + segmented tabs */
.section-header { display: grid; grid-template-columns: 1fr; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: #fafafa; }
.section-title { font-weight: 900; font-size: 18px; color: #6b7280; letter-spacing: .02em; justify-self: center; }
.seg { display: inline-flex; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 2px; }

.tab {
  padding: 8px 12px;
  font-weight: 700;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 8px;
}

.tab.active { color: #fff; background: var(--primary); }

.subtab-bar { display: flex; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.sub-seg { background: #fff; border: 1px solid var(--border); border-radius: 10px; width: max-content; margin: 10px 12px; padding: 2px; }
.subtab-text {
  width: max-content;
  margin: 12px auto;
  padding: 10px 18px;
  background: #0b5aa7;
  color: #fff;
  border-radius: 12px;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04) inset;
}

.subtab {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  cursor: pointer;
}

.subtab.active { background: var(--primary); color: #fff; }

.tab-panel { background: #fff; }
.tab-panel.active { display: block; }

.chart-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 12px;
}

.chart-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 6px; }
.chart-title { font-weight: 600; }
.muted { color: var(--muted); font-weight: 500; }

.chart-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  background: #fff;
}

.chart-placeholder {
  display: block;
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
}

.download-row { display: flex; justify-content: center; padding-top: 10px; }
.icp-inline { text-align: center; font-size: 12px; margin-top: 8px; }
.icp-inline a { color: #6b7280; text-decoration: none; }
.icp-inline a:hover { text-decoration: underline; }

/* PDF report styles (used only for export) */
.report-root { width: 800px; padding: 24px; font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial; color: #111827; }
.report-title { font-weight: 900; font-size: 20px; }
.report-sub { color: #6b7280; margin-bottom: 16px; }
.report-section-title { font-weight: 800; margin: 18px 0 10px; }
.report-card { border: 1px solid #e5e7eb; border-radius: 6px; padding: 12px; }
.report-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.report-badge { display: inline-block; background: #d8822c; color: #fff; font-weight: 800; border-radius: 6px; padding: 2px 8px; font-size: 12px; }

/* New compact survival grid */
.survival-title { font-weight: 900; color: #6b7280; margin-bottom: 4px; }
.survival-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 16px; }
.survival-item { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; }
.survival-left { grid-column: 1; grid-row: 1; font-weight: 900; font-size: 28px; letter-spacing: .02em; }
.survival-right { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: #111827; font-weight: 700; }
.survival-ci { grid-column: 1; grid-row: 2; color: #6b7280; font-size: 12px; }

.legend {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  padding: 12px;
}

.legend-title { font-weight: 700; margin-bottom: 8px; }

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
  display: grid;
  gap: 6px;
}

.legend-list li { display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.dot-vl { background: var(--vl); }
.dot-l { background: var(--l); }
.dot-ml { background: var(--ml); }
.dot-mh { background: var(--mh); }
.dot-h { background: var(--h); }
.dot-vh { background: var(--vh); }

.note { color: var(--muted); font-size: 12px; }
.cite { margin-top: 6px; }

.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { border-bottom: 1px solid var(--border); padding: 10px 12px; text-align: left; }
.data-table thead th { background: #fafafa; font-weight: 700; }

.placeholder { padding: 16px; color: var(--muted); }

@media (max-width: 1200px) {
  .chart-grid { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  :root { --sidebar-w: 280px; }
  .layout { grid-template-columns: 0 1fr; }
  .sidebar { position: fixed; z-index: 50; inset: 56px auto 0 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s ease; box-shadow: 0 8px 24px rgba(0,0,0,0.12); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .top-cards { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
}

/* Chart.js color helpers */
.line-vl { color: var(--vl); }
.line-l  { color: var(--l); }
.line-ml { color: var(--ml); }
.line-mh { color: var(--mh); }
.line-h  { color: var(--h); }
.line-vh { color: var(--vh); }

/* Overlay menu (left drawer) */
.overlay { position: fixed; inset: 0; pointer-events: none; z-index: 60; --drawer-w: var(--sidebar-w); }
.overlay-backdrop { position: absolute; top: 0; right: 0; bottom: 0; left: var(--drawer-w); background: rgba(0,0,0,0.35); opacity: 0; transition: opacity .2s ease; z-index: 0; }
.overlay-panel {
  position: absolute; left: 0; top: 0; height: 100%; width: var(--drawer-w);
  background: #fff; border-right: 1px solid var(--border);
  transform: translateX(-100%); transition: transform .25s ease; box-shadow: 8px 0 24px rgba(0,0,0,.12);
  display: flex; flex-direction: column; z-index: 1;
}
.overlay-list { display: grid; gap: 0; padding: 8px 0; }
.overlay-item { padding: 22px 24px; text-decoration: none; color: var(--text); font-weight: 700; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.overlay-item::after { content: '›'; color: var(--muted); font-weight: 700; }

.overlay.open { pointer-events: auto; }
.overlay.open .overlay-panel { transform: translateX(0); }
.overlay.open .overlay-backdrop { opacity: 1; }

.site-footer { text-align: center; color: #6b7280; padding: 16px 0 24px; font-size: 12px; }

