:root {
  --ink: #102a33;
  --ink-2: #33505b;
  --muted: #6f8791;
  --line: #e2ebee;
  --line-strong: #cfdde1;
  --bg: #f1f6f7;
  --card: #ffffff;
  --teal: #0d7c85;
  --teal-dark: #075d65;
  --teal-soft: #e6f3f4;
  --teal-mid: #bfe0e2;
  --amber: #b97722;
  --amber-soft: #fdf3e2;
  --red: #bf3b2f;
  --red-soft: #fdeceb;
  --green: #2c8a60;
  --green-soft: #e8f6ef;
  --blue: #2f6fa8;
  --blue-soft: #eaf2fa;
  --violet: #6b5aa8;
  --violet-soft: #f0edf9;
  --shadow: 0 1px 2px rgba(16, 42, 51, .04), 0 8px 24px rgba(16, 42, 51, .05);
  --shadow-lg: 0 24px 60px rgba(9, 38, 46, .18);
  --radius: 14px;
  --radius-sm: 9px;
  --sidebar: 232px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", "Source Han Sans SC", system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }
.svg-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c8d7db; border-radius: 9px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ------------------------------ 布局 ------------------------------ */
.layout { min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  background: linear-gradient(178deg, #0b2c34 0%, #0a252c 58%, #082027 100%);
  color: #d7e6e8;
  display: flex;
  flex-direction: column;
  padding: 22px 14px 16px;
  z-index: 40;
}
.brand {
  display: flex; align-items: center; gap: 11px;
  padding: 2px 8px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
  margin-bottom: 18px;
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 11px;
  background: linear-gradient(140deg, #1ba3a6, #0b6a73);
  display: grid; place-items: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .22);
  flex: none;
}
.brand-mark svg { width: 23px; height: 23px; fill: none; stroke: #fff; stroke-width: 1.5; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; }
.brand-text strong { color: #fff; font-size: 16px; letter-spacing: .5px; }
.brand-text small { color: #7fa2a8; font-size: 11px; margin-top: 3px; letter-spacing: 1.2px; }

.nav { flex: 1; overflow-y: auto; padding-right: 2px; }
.nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-color: transparent; }
.nav-group { margin-bottom: 19px; }
.nav-label {
  display: block; padding: 0 10px 7px;
  font-size: 10.5px; letter-spacing: 1.4px; color: #6c8e94; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; margin-bottom: 2px;
  border-radius: 9px; color: #b9cfd3; font-size: 13.5px;
  transition: background .16s, color .16s;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.6; flex: none; }
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #eef7f7; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(28, 156, 160, .24), rgba(28, 156, 160, .08));
  color: #fff;
  box-shadow: inset 2px 0 0 #2bb3b5;
}
.nav-item.active svg { stroke: #5fd0d0; }

.sidebar-foot { border-top: 1px solid rgba(255,255,255,.08); padding-top: 13px; }
.sidebar-status {
  display: flex; align-items: center; gap: 7px; padding: 0 10px 12px;
  color: #7fa2a8; font-size: 11.5px;
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: #45c48a; box-shadow: 0 0 0 3px rgba(69, 196, 138, .14); }
.sidebar-user { display: flex; align-items: center; gap: 9px; padding: 0 8px; }
.sidebar-user strong { display: block; font-size: 12.5px; color: #e6f1f2; font-weight: 600; }
.sidebar-user small { font-size: 11px; color: #74969c; }

.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 78px; flex: none;
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 0 30px;
  background: rgba(255, 255, 255, .86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 30;
}
.crumb { font-size: 11.5px; color: var(--muted); letter-spacing: .3px; margin-bottom: 2px; }
.topbar-title { display: flex; align-items: center; gap: 10px; }
.topbar-title h1 { font-size: 20px; font-weight: 650; letter-spacing: .2px; }
.topbar-actions { display: flex; align-items: center; gap: 9px; }

.view { padding: 26px 30px 50px; max-width: 1560px; width: 100%; margin: 0 auto; }

/* ------------------------------ 按钮 ------------------------------ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 15px;
  border-radius: 9px; border: 1px solid var(--line-strong);
  background: #fff; color: var(--ink-2);
  font-size: 13px; font-weight: 550; white-space: nowrap;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .1s;
}
.btn svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.btn:hover { border-color: #b6c8cd; background: #fbfdfd; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--teal); border-color: var(--teal); color: #fff; box-shadow: 0 4px 12px rgba(13, 124, 133, .22); }
.btn-primary:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn-soft { background: var(--teal-soft); border-color: transparent; color: var(--teal-dark); }
.btn-soft:hover { background: #d9edee; }
.btn-danger { color: var(--red); border-color: #ecc9c6; background: #fff; }
.btn-danger:hover { background: var(--red-soft); }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: #eef4f5; }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 7px; }
.btn-icon { width: 34px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------ 卡片与栅格 ------------------------------ */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card-pad { padding: 20px 22px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 17px 20px 14px;
}
.card-head h3 { font-size: 14.5px; font-weight: 650; }
.card-head .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.card-body { padding: 0 20px 18px; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.55fr) minmax(340px, 1fr); }
.grid-main > .card { display: flex; flex-direction: column; }
.grid-detail { grid-template-columns: minmax(0, 1.5fr) minmax(300px, .8fr); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.wrap { flex-wrap: wrap; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.strong { font-weight: 650; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.grow { flex: 1; min-width: 0; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-20 { margin-top: 20px; }

/* ------------------------------ 页头 ------------------------------ */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.page-head h2 { font-size: 17px; font-weight: 650; letter-spacing: .2px; }
.page-head p { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; gap: 9px; align-items: center; }

/* ------------------------------ KPI ------------------------------ */
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 17px 18px 15px; position: relative; overflow: hidden;
}
.stat::after {
  content: ""; position: absolute; right: -20px; top: -24px; width: 84px; height: 84px;
  border-radius: 50%; background: var(--tint, var(--teal-soft)); opacity: .55;
}
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; position: relative; z-index: 1; }
.stat-label { font-size: 12.5px; color: var(--muted); font-weight: 550; }
.stat-icon {
  width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center;
  background: var(--tint, var(--teal-soft)); color: var(--tone, var(--teal));
}
.stat-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.stat-value { font-size: 27px; font-weight: 660; letter-spacing: -.5px; line-height: 1.1; position: relative; z-index: 1; }
.stat-value small { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0; margin-left: 4px; }
.stat-foot { display: flex; align-items: center; gap: 6px; margin-top: 9px; font-size: 11.5px; color: var(--muted); position: relative; z-index: 1; }
.trend-up { color: var(--green); } .trend-down { color: var(--red); }

/* ------------------------------ 今日时间线 ------------------------------ */
.timeline { padding: 2px 20px 8px; }
.tl-item { display: grid; grid-template-columns: 52px 12px minmax(0, 1fr); gap: 10px; position: relative; padding-bottom: 17px; }
.tl-item:last-child { padding-bottom: 2px; }
.tl-item::before {
  content: ""; position: absolute; left: 63px; top: 17px; bottom: -2px; width: 1px; background: var(--line);
}
.tl-item:last-child::before { display: none; }
.tl-time { font-size: 12.5px; font-weight: 600; color: var(--ink-2); padding-top: 1px; font-variant-numeric: tabular-nums; }
.tl-dot { width: 9px; height: 9px; border-radius: 50%; background: #c6d6da; margin-top: 5px; position: relative; z-index: 1; border: 2px solid #fff; box-shadow: 0 0 0 1.5px #c6d6da; }
.tl-dot.done { background: var(--green); box-shadow: 0 0 0 1.5px var(--green); }
.tl-dot.live { background: var(--amber); box-shadow: 0 0 0 1.5px var(--amber); }
.tl-card { background: #f8fbfb; border: 1px solid #e8f0f1; border-radius: 10px; padding: 10px 12px; transition: .15s; }
.tl-card:hover { border-color: var(--teal-mid); background: #fff; box-shadow: 0 4px 14px rgba(16,42,51,.06); }
.tl-main { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.tl-name { font-weight: 600; font-size: 13.5px; }
.tl-meta { font-size: 11.5px; color: var(--muted); }
.tl-note { font-size: 11.5px; color: var(--amber); margin-top: 4px; }

/* ------------------------------ 图表 ------------------------------ */
.chart-box { padding: 4px 10px 0; }
.chart-svg { width: 100%; height: auto; display: block; overflow: visible; }
.bar-rect { fill: var(--teal-mid); transition: fill .15s; }
.bar-rect:hover { fill: var(--teal); }
.chart-label { font-size: 10.5px; fill: #8198a1; }
.chart-value { font-size: 10.5px; fill: #4e6a74; font-weight: 600; }
.chart-line { fill: none; stroke: var(--teal); stroke-width: 2.2; stroke-linejoin: round; stroke-linecap: round; }
.chart-area { fill: url(#areaGrad); }
.chart-dot { fill: #fff; stroke: var(--teal); stroke-width: 2; }

/* ------------------------------ 表格 ------------------------------ */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--muted);
  letter-spacing: .4px; text-transform: uppercase;
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: #fafcfc;
  white-space: nowrap;
}
.table td { padding: 12px 14px; border-bottom: 1px solid #edf3f4; vertical-align: middle; font-size: 13px; }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr { transition: background .12s; }
.table tbody tr.clickable { cursor: pointer; }
.table tbody tr.clickable:hover { background: #f7fbfb; }
.table .cell-main { font-weight: 600; font-size: 13.5px; }
.table .cell-sub { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .actions { text-align: right; white-space: nowrap; }
.table-empty { padding: 42px 20px; text-align: center; color: var(--muted); font-size: 13px; }

/* ------------------------------ 标签 ------------------------------ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 600; line-height: 1.6; white-space: nowrap;
  background: #eef3f4; color: #5f7780;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-teal { background: var(--teal-soft); color: var(--teal-dark); }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-amber { background: var(--amber-soft); color: var(--amber); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-violet { background: var(--violet-soft); color: var(--violet); }
.badge-gray { background: #eef2f3; color: #748a93; }

.tag {
  display: inline-block; padding: 1px 7px; border-radius: 5px;
  background: #f0f5f6; color: #587079; font-size: 11px; margin: 2px 3px 2px 0;
}
.tag.allergy { background: var(--red-soft); color: var(--red); font-weight: 600; }
.tag.qual { background: var(--blue-soft); color: var(--blue); }

/* ------------------------------ 头像 ------------------------------ */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--teal-soft); color: var(--teal-dark);
  font-size: 13px; font-weight: 650;
}
.avatar-sm { width: 31px; height: 31px; font-size: 11.5px; }
.avatar-lg { width: 58px; height: 58px; font-size: 19px; }
.avatar-amber { background: var(--amber-soft); color: var(--amber); }
.avatar-blue { background: var(--blue-soft); color: var(--blue); }
.avatar-violet { background: var(--violet-soft); color: var(--violet); }

/* ------------------------------ 工具栏 ------------------------------ */
.toolbar {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 13px 16px; border-bottom: 1px solid var(--line);
}
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; left: 11px; width: 15px; height: 15px; fill: none; stroke: #8aa0a8; stroke-width: 1.8; pointer-events: none; }
.search-box input {
  width: 220px; height: 34px; padding: 0 12px 0 32px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; outline: none;
}
.search-box input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,124,133,.1); }
.select, .input {
  height: 34px; padding: 0 10px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; outline: none;
}
.select:focus, .input:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,124,133,.1); }
textarea.input { height: auto; padding: 9px 11px; resize: vertical; min-height: 74px; line-height: 1.6; }
.seg { display: inline-flex; background: #eef4f5; border-radius: 8px; padding: 3px; gap: 2px; }
.seg a, .seg button {
  border: none; background: transparent; padding: 5px 11px; border-radius: 6px;
  font-size: 12px; color: var(--muted); white-space: nowrap;
}
.seg a.active, .seg button.active { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(16,42,51,.1); font-weight: 600; }

/* ------------------------------ 日期条 ------------------------------ */
.date-strip { display: flex; gap: 6px; overflow-x: auto; padding: 12px 16px 14px; }
.date-chip {
  flex: 1; min-width: 66px; text-align: center; padding: 8px 4px 7px;
  border: 1px solid transparent; border-radius: 10px; color: var(--muted);
  transition: .15s;
}
.date-chip small { display: block; font-size: 10.5px; margin-bottom: 3px; }
.date-chip strong { display: block; font-size: 16px; font-weight: 650; color: var(--ink-2); }
.date-chip span { display: block; font-size: 10px; margin-top: 3px; color: #9aadb3; }
.date-chip:hover { background: #f4f9f9; }
.date-chip.active { background: var(--teal); border-color: var(--teal); color: #d9f0f1; box-shadow: 0 5px 14px rgba(13,124,133,.2); }
.date-chip.active strong { color: #fff; }
.date-chip.active span { color: #b9e4e6; }
.date-chip.today:not(.active) { border-color: var(--teal-mid); }

/* ------------------------------ 患者 ------------------------------ */
.patient-hero { display: flex; align-items: center; gap: 16px; padding: 22px 24px; }
.patient-hero h2 { font-size: 20px; font-weight: 650; }
.patient-hero .meta { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 7px; color: var(--muted); font-size: 12.5px; }
.patient-hero .meta span { display: inline-flex; align-items: center; gap: 5px; }
.patient-hero .meta svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.8; }
.allergy-alert {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 0 24px 18px; padding: 11px 14px;
  background: var(--red-soft); border: 1px solid #f3d2cf; border-radius: 9px;
  color: #8e2f27; font-size: 12.5px;
}
.allergy-alert svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.8; flex: none; margin-top: 1px; }
.allergy-alert strong { font-weight: 650; }
.allergy-alert .detail { color: #a65a53; margin-top: 1px; }
.allergy-ok { background: var(--green-soft); border-color: #cde9dc; color: #236d4b; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); padding: 0 24px; }
.tab {
  padding: 12px 14px; font-size: 13px; color: var(--muted); border-bottom: 2px solid transparent;
  margin-bottom: -1px; cursor: pointer; background: none; border-top: 0; border-left: 0; border-right: 0;
}
.tab.active { color: var(--teal-dark); border-bottom-color: var(--teal); font-weight: 600; }
.tab-panel { padding: 18px 24px 24px; }

.kv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 13px 22px; }
.kv { min-width: 0; }
.kv label { display: block; font-size: 10.5px; color: var(--muted); letter-spacing: .5px; margin-bottom: 2px; }
.kv div { font-size: 13px; word-break: break-all; }
.kv.full { grid-column: 1 / -1; }

.stat-line { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mini-stat { background: #f8fbfb; border: 1px solid #eaf1f2; border-radius: 9px; padding: 10px 12px; }
.mini-stat label { display: block; font-size: 10.5px; color: var(--muted); }
.mini-stat strong { font-size: 17px; font-weight: 650; }

/* ------------------------------ 诊所 / 牙医卡片 ------------------------------ */
.entity-card { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.entity-top { display: flex; align-items: flex-start; gap: 12px; }
.entity-top h3 { font-size: 14.5px; font-weight: 650; }
.entity-top .sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.entity-stats { display: flex; gap: 18px; padding-top: 12px; border-top: 1px dashed var(--line); }
.entity-stats div { flex: 1; }
.entity-stats label { display: block; font-size: 10.5px; color: var(--muted); }
.entity-stats strong { font-size: 15px; font-weight: 650; }

/* ------------------------------ 详情列表 ------------------------------ */
.list { padding: 0 20px 6px; }
.list-item { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid #eef4f5; }
.list-item:last-child { border-bottom: none; }
.list-item .grow { min-width: 0; }
.list-item .title { font-size: 13px; font-weight: 550; }
.list-item .sub { font-size: 11px; color: var(--muted); margin-top: 1px; }
.list-item .right { text-align: right; font-size: 12px; white-space: nowrap; }

/* ------------------------------ 表单 ------------------------------ */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 550; color: var(--ink-2); margin-bottom: 5px; }
.field label .req { color: var(--red); margin-left: 2px; }
.field input, .field select, .field textarea {
  width: 100%; height: 37px; padding: 0 11px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field textarea { height: auto; min-height: 72px; padding: 9px 11px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(13,124,133,.1); }
.field .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.field.error input, .field.error select { border-color: var(--red); }
.check-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px 10px; }
.check {
  display: flex; align-items: center; gap: 7px; font-size: 12.5px;
  background: #f8fbfb; border: 1px solid #e7eff0; border-radius: 7px; padding: 7px 9px; cursor: pointer;
}
.check input { accent-color: var(--teal); }
.check input[type="checkbox"], .check input[type="radio"] {
  width: 16px; height: 16px; padding: 0; margin: 0; flex: none;
  border-radius: 3px; accent-color: var(--teal);
}
.check:hover { border-color: var(--teal-mid); }
.allergy-row {
  display: grid; grid-template-columns: 1.2fr .8fr 1.3fr 30px; gap: 7px; align-items: center;
  padding: 8px; background: #fbf6f5; border: 1px solid #f0dbd8; border-radius: 8px; margin-bottom: 7px;
}
.allergy-row input, .allergy-row select { height: 33px; border: 1px solid #e6d3d0; border-radius: 6px; padding: 0 8px; background: #fff; width: 100%; }
.allergy-row .icon-btn { color: var(--red); }
.icon-btn {
  width: 30px; height: 30px; border: none; background: transparent; border-radius: 6px;
  display: grid; place-items: center; color: var(--muted);
}
.icon-btn:hover { background: rgba(191,59,47,.08); color: var(--red); }
.icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }

/* ------------------------------ 弹窗 ------------------------------ */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(8, 29, 35, .46); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px; overflow-y: auto;
  animation: fadeIn .16s ease;
}
.modal {
  width: 560px; max-width: 100%; background: #fff; border-radius: 16px;
  box-shadow: var(--shadow-lg); overflow: hidden;
  animation: modalIn .18s ease;
}
.modal-lg { width: 760px; }
.modal-xl { width: 920px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 16px; font-weight: 650; }
.modal-head p { font-size: 12px; color: var(--muted); margin-top: 2px; }
.modal-close { border: none; background: #f3f7f8; width: 30px; height: 30px; border-radius: 7px; display: grid; place-items: center; color: var(--muted); }
.modal-close:hover { background: #e8f0f1; color: var(--ink); }
.modal-close svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.modal-body { padding: 18px 22px; max-height: calc(100vh - 220px); overflow-y: auto; }
.modal-foot { display: flex; align-items: center; justify-content: flex-end; gap: 9px; padding: 14px 22px 18px; border-top: 1px solid var(--line); background: #fbfdfd; }
.modal-foot .left { margin-right: auto; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn { from { opacity: 0; transform: translateY(10px) scale(.99); } to { opacity: 1; transform: none; } }

/* ------------------------------ Toast ------------------------------ */
.toast-root { position: fixed; right: 24px; bottom: 24px; z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.toast {
  display: flex; align-items: center; gap: 8px;
  background: #13323a; color: #eaf5f5; padding: 10px 15px; border-radius: 9px;
  box-shadow: 0 10px 30px rgba(9,38,46,.24); font-size: 13px;
  animation: toastIn .2s ease; max-width: 380px;
}
.toast.error { background: #7d2b24; }
.toast.success { background: #1c5c43; }
.toast svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; flex: none; }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ------------------------------ 空状态/加载 ------------------------------ */
.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 90px; color: var(--muted); }
.spinner { width: 17px; height: 17px; border: 2px solid #d4e3e5; border-top-color: var(--teal); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; padding: 44px 20px; color: var(--muted); }
.empty strong { display: block; color: var(--ink-2); font-size: 14px; margin-bottom: 4px; }
.empty svg { width: 34px; height: 34px; stroke: #b7c9cd; fill: none; stroke-width: 1.4; margin-bottom: 10px; }
.empty .btn { margin-top: 14px; }

/* ------------------------------ 结算单 ------------------------------ */
.invoice-sheet {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 34px 38px; box-shadow: var(--shadow); max-width: 820px; margin: 0 auto;
}
.inv-head { display: flex; justify-content: space-between; gap: 20px; padding-bottom: 20px; border-bottom: 2px solid var(--ink); }
.inv-brand { display: flex; align-items: center; gap: 12px; }
.inv-brand .logo { width: 44px; height: 44px; border-radius: 11px; background: var(--teal); display: grid; place-items: center; }
.inv-brand .logo svg { width: 25px; height: 25px; fill: none; stroke: #fff; stroke-width: 1.5; }
.inv-brand h2 { font-size: 18px; letter-spacing: .5px; }
.inv-brand p { font-size: 11px; color: var(--muted); margin-top: 2px; }
.inv-title { text-align: right; }
.inv-title h1 { font-size: 26px; letter-spacing: 2px; font-weight: 650; }
.inv-title .no { font-size: 12px; color: var(--muted); margin-top: 3px; font-variant-numeric: tabular-nums; }
.inv-parties { display: grid; grid-template-columns: 1.3fr 1fr 1fr; gap: 22px; padding: 22px 0; }
.inv-parties h4 { font-size: 10.5px; color: var(--muted); letter-spacing: 1px; margin-bottom: 5px; }
.inv-parties p { font-size: 12.5px; line-height: 1.7; }
.inv-table { width: 100%; border-collapse: collapse; margin-top: 6px; }
.inv-table th { font-size: 11px; color: var(--muted); text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); background: #f7fafb; }
.inv-table td { padding: 11px 10px; border-bottom: 1px solid #edf3f4; font-size: 12.5px; }
.inv-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.inv-total { display: flex; justify-content: flex-end; padding-top: 16px; }
.inv-total table { min-width: 240px; }
.inv-total td { padding: 5px 8px; font-size: 12.5px; }
.inv-total tr.grand td { border-top: 2px solid var(--ink); padding-top: 10px; font-size: 18px; font-weight: 650; }
.inv-foot { margin-top: 26px; padding-top: 14px; border-top: 1px dashed var(--line-strong); display: flex; justify-content: space-between; gap: 20px; font-size: 11px; color: var(--muted); }
.inv-stamp { color: var(--green); border: 1.5px solid var(--green); border-radius: 6px; padding: 3px 10px; font-weight: 700; letter-spacing: 2px; transform: rotate(-4deg); font-size: 15px; }
.inv-stamp.unpaid { color: var(--amber); border-color: var(--amber); }

/* ------------------------------ 业绩 ------------------------------ */
.perf-summary { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.perf-cell { padding: 14px 16px; border-radius: 11px; background: #f8fbfb; border: 1px solid #eaf1f2; }
.perf-cell label { display: block; font-size: 10.5px; color: var(--muted); }
.perf-cell strong { font-size: 19px; font-weight: 650; display: block; margin-top: 2px; }
.bar-track { height: 5px; background: #e9f0f1; border-radius: 5px; overflow: hidden; margin-top: 7px; }
.bar-fill { height: 100%; background: var(--teal); border-radius: 5px; }

/* ------------------------------ 打印 ------------------------------ */
@page { size: A4; margin: 0; }
@media print {
  body { background: #fff; }
  .sidebar, .topbar, .page-head, .page-actions, .toolbar, .no-print, .toast-root, .modal-backdrop { display: none !important; }
  .main { margin-left: 0; }
  .view { padding: 12mm 10mm; max-width: none; }
  .invoice-sheet { border: none; box-shadow: none; padding: 0; max-width: none; width: 100%; }
  .print-only { display: block !important; }
}
.print-only { display: none; }

/* ------------------------------ 响应式 ------------------------------ */
@media (max-width: 1180px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-main, .grid-detail { grid-template-columns: 1fr; }
  .perf-summary { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  :root { --sidebar: 0px; }
  .sidebar {
    transform: translateX(-100%);
    width: 232px;
    transition: transform .22s;
  }
  .sidebar.open { transform: none; box-shadow: 20px 0 60px rgba(0,0,0,.2); }
  .main { margin-left: 0; }
  .topbar { padding: 0 18px; height: 68px; }
  .view { padding: 18px 16px 40px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .check-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .check-grid.inline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kv-grid { grid-template-columns: 1fr; }
  .invoice-sheet { padding: 24px 18px; }
  .inv-parties { grid-template-columns: 1fr; gap: 14px; }
  .stat-line { grid-template-columns: repeat(2, 1fr); }
  .patient-hero { flex-wrap: wrap; align-items: flex-start; padding: 18px; }
  .patient-hero > .grow { flex: 1 1 calc(100% - 70px); min-width: 0; }
  .patient-hero h2 { font-size: 18px; }
  .patient-hero .meta { gap: 7px 14px; font-size: 12px; }
  .patient-hero .stat-line { width: 100%; min-width: 0 !important; margin-top: 4px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .patient-hero .stat-line .mini-stat { padding: 9px 10px; }
  .allergy-alert { margin: 0 18px 16px; }
  .perf-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .table { min-width: 680px; }
  .hide-mobile { display: none !important; }
  .mobile-menu { display: inline-flex !important; }
}
.mobile-menu { display: none; }
