:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --ink: #111827;
  --muted: #667085;
  --subtle: #98a2b3;
  --line: #d9e2ef;
  --primary: #1769e0;
  --primary-dark: #0d47a1;
  --sidebar: #0f1f3a;
  --check: #2f80ed;
  --lab: #16a6a3;
  --operation: #8b5cf6;
  --chemo: #4f8df7;
  --medication: #45b36b;
  --alert: #f59e0b;
  --danger: #ef4444;
  --shadow: 0 12px 34px rgba(15, 31, 58, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-width: 1440px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
.shell { display: grid; grid-template-columns: 236px minmax(1180px, 1fr); min-height: 100vh; }
.sidebar {
  width: 236px;
  background: linear-gradient(180deg, #10213d 0%, #091426 100%);
  color: #e9f1ff;
  padding: 22px 18px;
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  height: 100vh;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 4px 24px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display:grid; place-items:center; background: linear-gradient(135deg, #2f80ed, #22c6b8); font-weight: 900; }
.brand strong { display:block; font-size: 17px; }
.brand span { display:block; color:#91a3c1; font-size: 12px; margin-top: 3px; }
.nav-list { display:flex; flex-direction:column; gap: 6px; margin-top: 22px; }
.nav-list a { color:#b7c5dc; text-decoration:none; padding: 12px 13px; border-radius: 12px; cursor: default; font-weight: 600; font-size: 14px; }
.nav-list a.active { color:white; background: rgba(47,128,237,.22); box-shadow: inset 3px 0 0 #49a7ff; }
.sidebar-card { position:absolute; left:18px; right:18px; bottom:22px; padding: 15px; border-radius: 16px; background: rgba(255,255,255,.08); border:1px solid rgba(255,255,255,.1); }
.sidebar-card span, .sidebar-card em { display:block; color:#91a3c1; font-size:12px; font-style:normal; }
.sidebar-card strong { display:block; margin: 7px 0; }
.workspace { grid-column: 2; min-width: 1180px; overflow-x: hidden; }
.topbar {
  height: 92px;
  padding: 18px 28px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  background: rgba(255,255,255,.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: relative;
  z-index: 2;
}
.breadcrumb { color: var(--muted); font-size: 13px; margin-bottom: 6px; }
h1 { margin:0; font-size: 24px; letter-spacing: -.02em; }
.topbar-actions { display:flex; gap: 10px; }
button, select, input { font: inherit; }
button { border: 0; border-radius: 10px; padding: 9px 14px; cursor:pointer; font-weight: 700; transition:.16s; }
button:hover { transform: translateY(-1px); }
.ghost-btn { color:#344054; background:#f2f5fa; border:1px solid var(--line); }
.primary-btn, #applyRange, button.active { color:white; background: var(--primary); }
.app { padding: 22px 28px 44px; max-width: 1680px; }
.panel, .patient-card, .filter-card, .summary-strip {
  background: var(--card);
  border: 1px solid rgba(217,226,239,.95);
  box-shadow: var(--shadow);
  border-radius: 16px;
}
.patient-card { padding: 20px; display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 24px; align-items: center; margin-bottom: 14px; }
.patient-main { display: flex; align-items: center; gap: 14px; min-width: 0; }
.avatar { width: 54px; height: 54px; border-radius: 16px; display:grid; place-items:center; color:white; font-weight:900; background: linear-gradient(135deg, #1769e0, #21b7a8); box-shadow: 0 10px 24px rgba(23,105,224,.24); }
.patient-name { font-size: 23px; font-weight: 850; }
.patient-meta { color: var(--muted); margin-top: 5px; font-size: 14px; }
.patient-grid { min-width:0; display: grid; grid-template-columns: 1fr minmax(240px, 2.1fr) 1fr 1fr; gap: 10px; }
.patient-grid div { padding: 12px 14px; border-radius: 13px; background: #f7f9fc; border:1px solid #edf1f7; min-height: 68px; }
.patient-grid span { display:block; color: var(--muted); font-size: 12px; margin-bottom: 7px; }
.patient-grid strong { display:block; font-size: 14px; line-height: 1.38; }
.summary-strip { display:grid; grid-template-columns: repeat(4, 1fr); gap: 1px; overflow:hidden; margin-bottom: 14px; }
.summary-strip div { padding: 15px 18px; background: linear-gradient(180deg, #fff, #fbfcff); }
.summary-strip span { display:block; color: var(--muted); font-size: 12px; }
.summary-strip strong { display:block; margin-top: 4px; font-size: 24px; letter-spacing:-.02em; }
.filter-card { padding: 14px 16px; display:flex; justify-content:space-between; align-items:center; margin-bottom: 16px; }
.quick-ranges { display:flex; gap: 8px; }
.quick-ranges button { color: #475467; background:#f2f5fa; border:1px solid transparent; padding: 8px 12px; }
.quick-ranges button.active { color:white; background:var(--primary); }
.date-range { display:flex; align-items:center; gap: 8px; color: var(--muted); }
input, select { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background:white; color:var(--ink); outline:none; }
input:focus, select:focus { border-color:#8bb8ff; box-shadow:0 0 0 3px rgba(23,105,224,.1); }
.content-grid { display:grid; grid-template-columns: minmax(780px, 1fr) 380px; gap: 16px; margin-bottom:16px; align-items:stretch; }
.timeline-card, .detail-card, .chart-card { padding: 18px; }
.timeline-card, .detail-card { height: 100%; }
.detail-card { display:flex; flex-direction:column; overflow: hidden; }
.detail-card .event-detail { flex:1; overflow:auto; padding-right: 4px; }
.card-header { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; margin-bottom: 12px; min-width:0; }
.card-header > div:first-child { min-width: 220px; }
.timeline-actions { display:flex; align-items:center; gap:8px; flex-shrink:0; }
.zoom-btn { width:34px; padding-left:0; padding-right:0; font-size:16px; line-height:1; }
.zoom-slider { width: 132px; padding: 0; accent-color: var(--primary); }
.small { padding: 8px 11px; font-size: 13px; }
.timeline-settings { position:absolute; right:18px; top:58px; z-index:6; width: 380px; max-height: 520px; overflow:auto; padding: 12px; border:1px solid #d8e1ef; background:#fff; border-radius: 14px; box-shadow: 0 18px 46px rgba(15,31,58,.18); }
.timeline-card { position: relative; }
.settings-title { font-weight:800; font-size:14px; margin-bottom:10px; color:#1f2937; }
.settings-tree { display:flex; flex-direction:column; gap:10px; }
.tree-node { border:1px solid #e5edf7; border-radius:12px; background:#f8fbff; overflow:hidden; }
.tree-parent { display:flex; align-items:center; justify-content:space-between; gap:8px; padding:9px 10px; background:#fff; }
.tree-parent label { display:flex; align-items:center; gap:7px; font-weight:800; color:#344054; }
.tree-parent input, .tree-child input { width:14px; height:14px; margin:0; }
.tree-actions { display:flex; gap:5px; }
.tree-actions button { padding:4px 7px; border-radius:7px; font-size:12px; color:#475467; background:#f2f5fa; border:1px solid #dfe7f2; }
.tree-actions button:disabled { opacity:.35; cursor:not-allowed; }
.tree-children { padding:8px 10px 10px 28px; display:flex; flex-direction:column; gap:7px; max-height: 160px; overflow:auto; }
.tree-child { display:flex; align-items:center; gap:7px; color:#475467; font-size:12px; }
.tree-empty { color:#98a2b3; font-size:12px; }
.card-header h2 { margin:0 0 5px; font-size:18px; }
.card-header p { margin:0; color:var(--muted); font-size:13px; }
.card-header.compact { align-items:center; }
.card-header.compact span { color:var(--muted); font-size:13px; background:#f2f5fa; padding:5px 9px; border-radius:999px; }
.legend { display:grid; grid-template-columns: repeat(6, 90px); gap:7px; justify-content:start; justify-items:stretch; max-width: 620px; margin: 0 0 10px 0; }
.legend-item { display:flex; align-items:center; justify-content:flex-start; gap:6px; min-width:0; font-size:12px; color:#475467; background:#f7f9fc; border:1px solid #edf1f7; border-radius:999px; padding:5px 8px; white-space:nowrap; }
.legend-dot { flex:0 0 auto; width:8px; height:8px; border-radius:50%; }
.timeline-shell { overflow-x:auto; overflow-y:hidden; border-radius:14px; border:1px solid #cfd8e6; background:#fff; }
#timelineSvg { display:block; min-width: 1280px; height: 548px; flex: 0 0 auto; }
#chartSvg { display:block; width:100%; height: 330px; border-radius:14px; border:1px solid #d8e1ef; background: linear-gradient(#ffffff, #fbfdff); }
.event-detail { color: var(--ink); line-height:1.65; }
.event-detail.empty { color: var(--muted); background:#f7f9fc; padding: 16px; border-radius:14px; border:1px dashed #d8e1ef; }
.detail-row { margin-bottom:13px; padding-bottom:13px; border-bottom:1px solid #edf1f7; }
.detail-row:last-child { border-bottom:0; }
.detail-actions { margin-top:auto; padding-top:14px; border-top:1px solid #edf1f7; }
.detail-actions .primary-btn { width:100%; }
.detail-label { font-size:12px; color:var(--muted); margin-bottom:4px; }
.detail-value { font-size:14px; word-break:break-word; }
.group-head { padding: 12px 14px; border-radius: 12px; background: #f7f9fc; border: 1px solid #edf1f7; margin-bottom: 12px; }
.group-head strong { display:block; font-size:15px; margin-bottom:4px; }
.group-head span { color: var(--muted); font-size: 12px; }
.group-list { display:flex; flex-direction:column; gap:8px; max-height: 420px; overflow:auto; padding-right: 4px; }
.group-item { width:100%; display:flex; gap:10px; align-items:flex-start; text-align:left; background:#fff; border:1px solid #edf1f7; border-radius:12px; padding:10px; color:var(--ink); font-weight:400; }
.group-item:hover { background:#f8fbff; transform:none; border-color:#cfe0f7; }
.group-item i { flex:0 0 auto; width:9px; height:9px; border-radius:50%; margin-top:6px; }
.group-item span { min-width:0; }
.group-item b { display:block; font-size:13px; margin-bottom:3px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; max-width: 100%; }
.group-item em { display:block; font-style:normal; color:var(--muted); font-size:12px; line-height:1.45; max-height: 34px; overflow:hidden; }
.back-to-group { width:100%; margin-bottom:12px; color:#175cd3; background:#eef4ff; border:1px solid #c7d7fe; text-align:left; }
.back-to-group:hover { transform:none; background:#e0ebff; }
.node { cursor:pointer; filter: drop-shadow(0 4px 7px rgba(15,31,58,.14)); }
.node:hover { stroke:#172033; stroke-width:2; }
.aggregate-node { stroke: #fff; stroke-width: 3; }
.aggregate-node:hover { stroke: #172033; stroke-width: 2; }
.bar { cursor:pointer; filter: drop-shadow(0 5px 8px rgba(15,31,58,.14)); }
.axis-label { fill: var(--muted); font-size: 12px; }
.month-label { font-weight: 800; fill: #64748b; }
.lane-label { fill: #334155; font-size: 14px; font-weight: 850; }
.month-line { stroke: #e4ebf5; stroke-width:1; }
.lane-line { stroke:#dce5f1; stroke-width:1; }
.tooltip { position:fixed; pointer-events:none; max-width:380px; padding:10px 12px; border-radius:12px; background:rgba(17,24,39,.95); color:white; font-size:13px; line-height:1.5; z-index:20; box-shadow:0 12px 30px rgba(0,0,0,.22); }
.tooltip strong { display:block; margin-bottom:3px; }
.metric-line { fill:none; stroke: var(--primary); stroke-width:3; }
.metric-area { fill: rgba(23,105,224,.12); }
.metric-point { fill:white; stroke:var(--primary); stroke-width:3; cursor:pointer; }
.metric-point.abnormal { stroke:var(--danger); }
.modal-mask { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .42); display: grid; place-items: center; padding: 32px; }
.modal-mask[hidden] { display: none; }
.modal-panel { width: min(980px, calc(100vw - 80px)); max-height: calc(100vh - 80px); background: #fff; border-radius: 18px; box-shadow: 0 28px 80px rgba(15,31,58,.3); display:flex; flex-direction:column; overflow:hidden; }
.modal-header { padding: 18px 22px; border-bottom:1px solid #e5edf7; display:flex; justify-content:space-between; gap:16px; align-items:flex-start; background: linear-gradient(180deg, #fff, #f8fbff); }
.modal-header h2 { margin:0 0 5px; font-size:20px; }
.modal-header p { margin:0; color:var(--muted); font-size:13px; }
.modal-close { width:34px; height:34px; padding:0; border-radius:50%; background:#f2f5fa; color:#475467; font-size:22px; line-height:1; }
.modal-body { padding: 22px 28px; overflow:auto; }
.medical-doc { color:#1f2937; line-height:1.85; font-size:15px; }
.medical-doc h3 { text-align:center; font-size:24px; margin: 4px 0 22px; letter-spacing:.08em; }
.medical-doc h4 { font-size:16px; margin: 18px 0 8px; color:#111827; border-left:4px solid var(--primary); padding-left:9px; }
.medical-doc p { margin:0; text-indent:2em; }
.medical-doc ol, .medical-doc ul { margin:0; padding-left: 28px; }
.medical-doc footer { margin-top:24px; padding:12px 14px; border-radius:12px; background:#fff7ed; color:#9a3412; font-size:13px; text-indent:0; }
.summary-doc h3 { text-align:left; letter-spacing:0; }
