@import url('https://cdn.jsdelivr.net/npm/lxgw-wenkai-webfont@1.7.0/lxgwwenkai-regular.css');

:root {
  --paper: #f7f1e3;
  --card: #fffdf6;
  --line: #d9cba6;
  --ink: #2b2b2b;
  --muted: #8a7a5c;
  --red: #8c2b2b;
  --red-dark: #6e1f1f;
  --green: #2f6b3a;
  --amber: #9a6b1f;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: 'LXGW WenKai', 'KaiTi', 'STKaiti', serif;
  font-size: 15px;
  line-height: 1.7;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.danger { color: var(--red); }

/* 顶栏 */
.topbar {
  background: var(--card);
  border-bottom: 2px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.topbar h1 { margin: 0; font-size: 22px; color: var(--red); letter-spacing: 4px; }
.topbar .ver { font-size: 12px; color: var(--muted); }
.topbar .back {
  color: var(--red);
  text-decoration: none;
  font-size: 15px;
  padding: 2px 10px 2px 0;
  border-right: 1px solid var(--line);
  margin-right: 2px;
}

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 18px;
}

/* 按钮 */
.btn {
  border: 1px solid var(--red);
  background: transparent;
  color: var(--red);
  padding: 7px 16px;
  border-radius: 5px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { background: #f3e7d8; }
.btn.primary { background: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.danger { border-color: #b08080; color: var(--red); }

.link-btn {
  border: none;
  background: none;
  color: var(--red);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  text-decoration: underline;
}
.link-btn.danger { color: var(--red); }
.link-btn:disabled { opacity: .45; cursor: not-allowed; }
.link-btn.muted { color: var(--muted); }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--card);
}
.badge.done { color: var(--green); border-color: #9cbfa4; }
.badge.running { color: var(--amber); border-color: #d8bd8a; }
.badge.failed { color: var(--red); border-color: #d3a0a0; }
.badge.small { padding: 1px 7px; font-size: 11px; }
.badge.stale { color: #7a6a4a; border-color: #c9b98f; background: #f3ecda; }

/* 首页 */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.page-head h2 { margin: 0; font-size: 18px; }
.head-tools { display: flex; gap: 10px; align-items: center; }
.head-tools input[type=text] {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: inherit;
  width: 220px;
  background: #fff;
}
.patient-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.patient-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(120, 100, 60, .08);
}
.pc-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pc-name { font-size: 18px; font-weight: bold; }
.pc-meta { color: var(--muted); font-size: 13px; }
.pc-actions { margin-left: auto; display: flex; gap: 8px; }
.pc-cases { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 8px; }
.case-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 2px;
  font-size: 14px;
  flex-wrap: wrap;
}
.case-txt { color: var(--ink); }
.case-formula { color: var(--muted); font-size: 13px; }
.case-row.child {
  margin-left: 30px;
  padding-left: 12px;
  border-left: 2px solid var(--line);
}

/* 弹窗 */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(60, 45, 20, .48);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.modal {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px 22px 16px;
  width: 400px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(80, 60, 25, .25);
}
.modal h3 { margin: 0 0 12px; color: var(--red); }
.modal-close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: none;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}
.modal-close:hover { color: var(--red); }
.modal label { display: block; margin-bottom: 12px; font-size: 14px; }
.modal input, .modal select, .modal textarea {
  width: 100%;
  margin-top: 6px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
.modal textarea { resize: none; }
.modal input::placeholder, .modal textarea::placeholder { color: #a08f70; }
.date-sel select {
  flex: 1;
  min-width: 0;
  margin-top: 0;
}
.date-sel {
  display: flex;
  gap: 8px;
  width: 100%;
  margin-top: 6px;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 8px; }
.req { color: var(--red); }

/* 登录/注册卡片 */
.auth-card { max-width: 400px; margin: 48px auto; padding: 28px 32px; }
.auth-card h2 { margin-top: 0; }
.auth-card .sub { margin: 0 0 18px; font-size: 13px; }
.auth-card label { display: block; margin-bottom: 14px; font-size: 14px; }
.auth-card input {
  width: 100%;
  margin-top: 6px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
.auth-card input:focus { outline: none; border-color: var(--red); }
.auth-card .btn.primary { width: 100%; margin-top: 6px; padding: 9px 16px; font-size: 15px; }
.auth-links { display: flex; justify-content: space-between; align-items: center; margin-top: 14px; font-size: 13px; }

/* 管理台 */
.tab.on { background: #e9d9b8; border-color: var(--red); color: var(--red); }
.admin-guide {
  background: #fdf3e0;
  border: 1px solid #e0c98f;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13.5px;
  line-height: 1.9;
}
.tab-hint {
  background: #fbf7ec;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0 0 12px;
  font-size: 13px;
  color: #6e5a30;
  line-height: 1.8;
}
.inv-form { max-width: 460px; }
.inv-form label { display: block; margin-bottom: 12px; font-size: 13.5px; }
.inv-form input, .inv-form select {
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
.inv-form .hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* 草稿恢复横幅 */
.resume-banner {
  background: #fdf3e0;
  border: 1px solid #e0c98f;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* 软提示 */
.soft-list { margin: 6px 0 12px; }
.soft-item { padding: 3px 0; font-size: 14px; }
.btn.is-locked { opacity: .55; }
.error-text { color: var(--red); }
.req-note {
  font-size: 13px;
  color: #6e5a30;
  background: #fdf3e0;
  border: 1px solid #e0c98f;
  border-radius: 6px;
  padding: 8px 12px;
  margin: 0 0 12px;
}

/* 管理员用量 */
.owner-table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.owner-table th, .owner-table td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; }
.owner-table th { background: #f4ecda; }

/* 人体部位图 */
.body-tabs { margin: 6px 0 4px; display: flex; gap: 6px; }
.body-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
  padding: 3px 14px;
  border-radius: 4px;
  font-family: inherit;
  cursor: pointer;
}
.body-tab.on { background: #e9d9b8; border-color: var(--red); color: var(--red); }
.body-svgs { display: flex; gap: 8px; margin-bottom: 4px; }
.bodyfig .silhouette { fill: #f6efdc; stroke: #2b2b2b; stroke-width: 1.2; }
.bodyfig .region { fill: rgba(140, 43, 43, .08); stroke: rgba(43, 43, 43, .35); stroke-width: .6; cursor: pointer; }
.bodyfig .region:hover { fill: rgba(140, 43, 43, .18); }
.bodyfig .region.is-selected { fill: rgba(140, 43, 43, .45); stroke: var(--red); }
.bodyfig .joint { fill: rgba(140, 43, 43, .1); stroke: rgba(43, 43, 43, .4); stroke-width: .6; cursor: pointer; }
.bodyfig .joint.is-selected { fill: rgba(140, 43, 43, .55); }
.bodyfig .detail { pointer-events: none; }
.bm-echo { font-size: 13px; margin-top: 2px; }

/* 腹部自按指引 */
.guide-card { margin: 8px 0; border: 1px solid var(--line); border-radius: 6px; background: #fbf7ec; }
.guide-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  user-select: none;
}
.guide-title { font-size: 13.5px; color: var(--red); }
.guide-toggle { font-size: 12px; color: var(--muted); }
.guide-body { padding: 4px 12px 10px; }
.guide-card.collapsed .guide-body { display: none; }
.guide-p { margin: 6px 0; font-size: 13.5px; line-height: 1.8; }
.guide-fig { text-align: center; margin-top: 8px; }
.abd-svg { width: 300px; max-width: 100%; height: auto; }
.guide-cap { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* 问诊单页 */
.intake-meta {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
  font-size: 13px;
  flex-wrap: wrap;
}
.intake-page { padding-bottom: 110px; }
.section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 12px;
}
.section[open] { padding-bottom: 12px; }
.section-title {
  cursor: pointer;
  padding: 11px 16px;
  font-weight: bold;
  color: var(--red);
  list-style: none;
  user-select: none;
}
.section-title::-webkit-details-marker { display: none; }
.section-title::before { content: '▸ '; }
.section[open] > .section-title::before { content: '▾ '; }

.q-item { padding: 8px 16px 4px; }
.q-item.flash-target {
  outline: 2px solid var(--red);
  outline-offset: 3px;
  border-radius: 4px;
  background: #fdf6e9;
}
.q-text { font-size: 14px; margin-bottom: 4px; }
.q-item input[type=text], .q-item input[type=number], .q-item textarea {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  background: #fff;
  font-size: 14px;
}
.num-wrap { display: flex; align-items: center; gap: 8px; }
.num-wrap input { flex: 1; }
.unit-suffix { color: var(--muted); font-size: 13px; white-space: nowrap; }
.q-item input:disabled, .q-item textarea:disabled { background: #f0e9d8; color: #666; }

.opt-row { display: flex; flex-wrap: wrap; gap: 8px; }
.opt {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 5px 12px;
  border-radius: 18px;
  cursor: pointer;
  font-size: 13.5px;
}
.opt input { margin: 0; }
.opt.on { background: #e9d9b8; border-color: var(--red); color: var(--red); }
.opt.on input { accent-color: var(--red); }

.slider-row { display: flex; align-items: center; gap: 10px; }
.slider-row input[type=range] { flex: 1; accent-color: var(--red); }
.slider-val { min-width: 130px; color: var(--red); font-size: 13px; }
.slider-labels { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }

.photo-drop {
  border: 1.5px dashed var(--line);
  border-radius: 6px;
  padding: 10px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: #fbf7ec;
  margin-bottom: 8px;
  font-size: 13.5px;
}
.photo-drop.drop-hover { border-color: var(--red); background: #f7ecd9; color: var(--red); }
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-thumb {
  position: relative;
  width: 86px;
  height: 86px;
  border: 1px solid var(--line);
  border-radius: 5px;
  overflow: hidden;
  background: #fff;
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(140, 43, 43, .85);
  color: #fff;
  cursor: pointer;
  line-height: 1;
  font-size: 13px;
}

.actionbar {
  position: sticky;
  bottom: 0;
  background: var(--card);
  border-top: 2px solid var(--line);
  padding: 10px 0;
  z-index: 20;
}
.actionbar-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.actionbar-inner .btn.primary { margin-left: auto; }

/* 医案页 */
.case-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.paper {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 36px 44px;
  max-width: 860px;
  margin: 0 auto 40px;
  box-shadow: 0 2px 6px rgba(120, 100, 60, .1);
}
.paper-head { border-bottom: 2px solid var(--line); margin-bottom: 18px; }
.paper-head h2 { margin: 0 0 4px; }
.stage-block { margin-bottom: 26px; }
.stage-bar { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.prompt-box {
  background: #f6f0e2;
  border-left: 3px solid var(--line);
  padding: 8px 12px;
  margin: 6px 0 12px;
  font-size: 13px;
  color: #5c5342;
}
.prompt-label { font-size: 12px; color: var(--muted); }
.prompt-toggle { font-size: 12.5px; }
.error-text { color: var(--red); }

/* 原始问诊单 */
.raw-wrap { border-bottom: 1px solid var(--line); padding: 6px 2px 10px; margin-bottom: 8px; }
.raw-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.raw-body { margin-top: 8px; }
.raw-group { margin-bottom: 8px; }
.raw-group-title { font-weight: bold; color: var(--red); font-size: 13.5px; margin: 6px 0 2px; }
.raw-item { font-size: 13.5px; padding: 1px 0 1px 10px; border-left: 2px solid var(--line); margin-bottom: 3px; }

.md-body h1, .md-body h2, .md-body h3 { color: var(--red); }
.md-body h1 { font-size: 20px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.md-body h2 { font-size: 17px; }
.md-body h3 { font-size: 15px; }
.md-body table { border-collapse: collapse; width: 100%; margin: 10px 0; font-size: 13.5px; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.md-body th { background: #f4ecda; }
.md-body code { background: #f3ecdd; padding: 1px 5px; border-radius: 3px; font-size: 12.5px; }
.md-body hr { border: none; border-top: 1px solid var(--line); margin: 16px 0; }
.md-body p { margin: 8px 0; }

/* 充值页 */
.recharge-paper { max-width: 560px; padding: 24px 28px; }
.recharge-paper h3 { color: var(--red); margin: 18px 0 8px; font-size: 16px; }
.recharge-paper .lead { margin-top: 0; font-size: 13.5px; line-height: 1.9; }
.recharge-tip {
  background: #fdf3e0;
  border: 1px solid #e0c98f;
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13.5px;
  color: #7a5b1a;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.qr-box { text-align: center; border: 1px dashed var(--line); border-radius: 6px; padding: 12px; background: #fbf7ec; }
.qr-box img { width: 200px; height: 200px; object-fit: contain; }
.qr-cap { margin: 4px 0 0; font-size: 12px; }
.qr-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.qr-row .qr-box { flex: 1; min-width: 220px; max-width: 280px; }
.qr-empty {
  border: 1px dashed var(--line);
  border-radius: 6px;
  padding: 26px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 2;
  background: #fbf7ec;
}
.amount-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.amount-btn {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 10px 8px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
}
.amount-btn b { display: block; color: var(--red); font-size: 16px; }
.amount-btn span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }
.amount-btn:hover { background: #f3e7d8; }
.amount-btn.on { background: #e9d9b8; border-color: var(--red); }
.amount-btn.dim { opacity: .45; cursor: not-allowed; }
.recharge-note { display: block; margin-top: 14px; font-size: 13px; color: var(--muted); }
.recharge-note input {
  width: 100%;
  margin-top: 5px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  background: #fff;
}
.btn-block { width: 100%; margin-top: 10px; padding: 9px 16px; font-size: 15px; }
.pay-steps {
  margin-top: 16px;
  border: 1px solid #e0c98f;
  border-radius: 6px;
  background: #fdf3e0;
  padding: 12px 16px;
}
.pay-steps h3 { margin: 0 0 8px; }
.pay-steps p { margin: 6px 0; font-size: 13.5px; line-height: 1.8; }
.pay-steps .code {
  font-size: 20px;
  color: var(--red);
  letter-spacing: 3px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 1px 8px;
}
.shot-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.shot-drop {
  border: 1.5px dashed var(--line);
  border-radius: 6px;
  padding: 10px 14px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: #fff;
  font-size: 13px;
  flex: 1;
}
.shot-drop.drag { border-color: var(--red); background: #f7ecd9; color: var(--red); }
.steps {
  background: #fdf3e0;
  border: 1px solid #e0c98f;
  border-radius: 6px;
  padding: 10px 14px;
  margin-bottom: 12px;
  font-size: 13.5px;
  line-height: 1.9;
}
.steps p { margin: 4px 0; }
.hint-line { margin: 6px 0 0; font-size: 12.5px; }

/* 管理台收款码 */
.qr-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.qr-card { border: 1px solid var(--line); border-radius: 8px; background: var(--card); padding: 14px 16px; }
.qr-card h3 { margin: 0 0 4px; color: var(--red); font-size: 16px; }
.qr-card .muted { margin: 0 0 10px; font-size: 12.5px; }
.qr-preview {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbf7ec;
  padding: 10px;
  text-align: center;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.qr-preview img { max-width: 200px; max-height: 200px; object-fit: contain; }
.qr-empty2 { color: var(--muted); font-size: 13px; }
.qr-drop {
  border: 1.5px dashed var(--line);
  border-radius: 6px;
  padding: 14px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  background: #fff;
  margin: 10px 0 6px;
  font-size: 13.5px;
}
.qr-drop.drag { border-color: var(--red); background: #f7ecd9; color: var(--red); }
.qr-stage {
  border: 1px solid #e0c98f;
  background: #fdf3e0;
  border-radius: 6px;
  padding: 10px;
  margin-top: 8px;
  text-align: center;
}
.qr-stage img { max-width: 180px; max-height: 180px; object-fit: contain; border: 1px solid var(--line); background: #fff; border-radius: 4px; }
.qr-stage-actions { margin-top: 8px; display: flex; gap: 8px; justify-content: center; }
.qr-msg { min-height: 20px; font-size: 13px; color: var(--muted); margin-top: 6px; }
.qr-msg.ok { color: var(--green); }
.qr-actions { display: flex; gap: 8px; margin-top: 8px; }
@media (max-width: 700px) { .qr-grid { grid-template-columns: 1fr; } }

@media print {
  .topbar, .case-actions, .actionbar { display: none; }
  body { background: #fff; }
  .paper { border: none; box-shadow: none; padding: 0; max-width: none; }
}
