/* ================ 设计令牌 ================ */
:root {
  --bg: #f6f4ee;
  --bg-soft: #fbfaf5;
  --panel: #ffffff;
  --ink: #1f2937;
  --ink-soft: #4b5563;
  --muted: #94a3b8;
  --line: #e8e2d4;
  --line-soft: #efeadd;
  --accent: #7a3b2e;          /* 朱褐 */
  --accent-2: #2f6b5b;        /* 松翠 */
  --accent-soft: #faf1ec;
  --warning: #b45309;
  --danger: #b91c1c;
  --ok: #15803d;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 4px 16px rgba(15,23,42,.06);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sticky-bar-h: 64px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC",
    "Helvetica Neue", "Microsoft YaHei", "Hiragino Sans GB",
    "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 14px;
}
::selection { background: rgba(122, 59, 46, .18); }

/* ================ 布局 ================ */
#app {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 100vh;
}
.sidebar {
  background: linear-gradient(180deg, #20322c 0%, #14241f 100%);
  color: #d6e4dc;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 90;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 4px 6px 18px; }
.logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #c9714b, #7a3b2e);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700; font-size: 18px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.brand-text .title { font-size: 16px; font-weight: 600; color: #fff; letter-spacing: 1px; }
.brand-text .subtitle { font-size: 12px; opacity: .75; }
.nav { display: flex; flex-direction: column; gap: 2px; margin-top: 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: #cdd9d2;
  font-size: 14px;
  transition: background .15s, color .15s;
}
.nav-item:hover { background: rgba(255,255,255,.05); color: #fff; }
.nav-item.active {
  background: rgba(255,255,255,.10);
  color: #fff;
  box-shadow: inset 2px 0 0 #c9714b;
}
.nav-item .ico {
  width: 22px; text-align: center; font-size: 16px;
  opacity: .85;
}
.sidebar-footer {
  margin-top: auto; padding: 10px 6px;
  color: rgba(255,255,255,.45);
  font-size: 12px;
}
.sidebar-mask { display: none; }
.menu-btn { display: none; }

.main {
  padding: 24px 28px 80px;
  min-width: 0;
}

/* 移动端 */
@media (max-width: 800px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; left: -240px; top: 0; bottom: 0;
    width: 220px;
    transition: left .22s ease;
  }
  body.sidebar-open .sidebar { left: 0; }
  body.sidebar-open .sidebar-mask {
    display: block; position: fixed; inset: 0;
    background: rgba(0,0,0,.36); z-index: 80;
  }
  .menu-btn {
    display: grid; place-items: center;
    position: fixed; top: 12px; left: 12px;
    width: 38px; height: 38px;
    background: var(--accent); color: #fff;
    border: none; border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 70;
    font-size: 18px; cursor: pointer;
  }
  .main {
    padding: 60px 14px 110px;
  }
  .page-header {
    flex-direction: column; align-items: flex-start; gap: 10px;
  }
  .page-header .toolbar {
    width: 100%;
  }
  .search input { width: 100%; }
  #herbsCard { overflow-x: hidden; }
  .herbs-desktop-only { display: none !important; }
  .herbs-mobile-only { display: block; }
  .az-index { gap: 6px; padding: 10px 0; }
  .az-index .az-item {
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 10px;
    font-size: 13px;
    box-sizing: border-box;
  }
  .herbs-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .herbs-toolbar .btn { width: 100%; justify-content: center; }
  .stat-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .table { font-size: 13px; }
  .table th, .table td { padding: 8px 8px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr !important; }
  .split { grid-template-columns: 1fr !important; }
  .rx-layout { grid-template-columns: 1fr !important; }
  .rx-list .row {
    grid-template-columns: 1fr 80px 90px 80px 28px;
    gap: 6px;
  }
  .modal { width: 96vw !important; max-height: 92vh; }
}

/* ================ 通用组件 ================ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-title { font-size: 20px; font-weight: 600; }
.page-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}
.card + .card { margin-top: 16px; }
.card .card-title {
  font-size: 14px; font-weight: 600; margin: 0 0 12px;
  color: var(--ink);
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
}
.card .card-title::before {
  content: ''; width: 3px; height: 14px; background: var(--accent);
  border-radius: 2px;
}
.card.collapsible .card-title { cursor: pointer; }
.card.collapsible.collapsed .card-body { display: none; }
.card.collapsible .card-title::after {
  content: '▾'; margin-left: auto; color: var(--muted); transition: transform .2s;
}
.card.collapsible.collapsed .card-title::after { transform: rotate(-90deg); }

.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  transition: all .15s;
}
.btn:hover { border-color: #c9c0aa; background: #fdfbf3; }
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { background: #66301f; border-color: #66301f; }
.btn.secondary { background: var(--accent-2); color: #fff; border-color: var(--accent-2); }
.btn.secondary:hover { background: #225447; border-color: #225447; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { background: #fff1f0; border-color: #fca5a5; }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn.icon { padding: 6px 8px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.input, .select, .textarea {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(122,59,46,.12);
}
.textarea { min-height: 64px; resize: vertical; line-height: 1.6; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > label { font-size: 12px; color: var(--ink-soft); }
.grid { display: grid; gap: 12px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

.tag {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  font-size: 12px;
}
.tag.green { background: #ecf6f1; color: var(--accent-2); }
.tag.gray  { background: #eef0f3; color: var(--ink-soft); }
.tag.warn  { background: #fff7ed; color: var(--warning); }

/* 登录页 */
body.login-page #app { grid-template-columns: 1fr !important; }
body.login-page .sidebar,
body.login-page .menu-btn,
body.login-page .sidebar-mask { display: none !important; }
body.login-page .main { padding: 0 !important; }
.auth-wrap {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(60% 60% at 30% 20%, rgba(122,59,46,.10), transparent 70%),
    radial-gradient(60% 60% at 80% 90%, rgba(43,109,90,.08), transparent 70%),
    var(--bg);
  padding: 24px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: #fff; border: 1px solid var(--line);
  border-radius: 16px; padding: 28px 28px 22px;
  box-shadow: 0 10px 40px rgba(0,0,0,.06);
}
.auth-brand {
  display: flex; align-items: center; gap: 14px;
  margin-bottom: 20px;
}
.auth-brand .logo {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700;
}
.auth-brand .title { font-size: 17px; font-weight: 600; color: var(--ink); }
.auth-brand .subtitle { font-size: 12px; color: var(--muted); margin-top: 2px; }
.auth-tabs {
  display: flex; gap: 8px; border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.auth-tabs .tab {
  padding: 8px 4px; cursor: pointer;
  font-size: 14px; color: var(--muted);
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.auth-tabs .tab.active { color: var(--accent); border-color: var(--accent); font-weight: 500; }
.auth-form .field { margin-bottom: 12px; }
.auth-form .field label small { color: var(--muted); margin-left: 4px; font-weight: normal; }
.auth-btn { width: 100%; padding: 10px; font-size: 14px; margin-top: 4px; }
.auth-tip { color: var(--muted); font-size: 12px; margin-top: 10px; line-height: 1.6; }
.auth-foot {
  text-align: center; color: var(--muted);
  font-size: 11px; margin-top: 18px; padding-top: 14px;
  border-top: 1px dashed var(--line);
}
.auth-foot .muted { color: #cbd5e1; }
.user-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 10px;
  background: var(--accent-soft);
  margin: 12px 8px;
  font-size: 13px;
}
.user-chip .who { flex: 1; min-width: 0; }
.user-chip .who .name { color: var(--ink); font-weight: 500; }
.user-chip .who .role { color: var(--muted); font-size: 11px; }
.user-chip .out {
  font-size: 11px; padding: 4px 8px;
  background: #fff; color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 6px;
  cursor: pointer;
}
.user-chip .out:hover { color: var(--danger); border-color: var(--danger); }

/* 联想词管理页 */
.phrase-section { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.phrase-section:last-child { border-bottom: none; }
.phrase-section-title {
  font-size: 13px; font-weight: 600; color: var(--ink);
  margin-bottom: 8px;
}
.phrase-section-title .muted {
  font-weight: normal; font-size: 12px; color: var(--muted); margin-left: 4px;
}
.phrase-section .table { margin-top: 0; }
.phrase-editor .field > label { display: flex; align-items: baseline; gap: 6px; }

.search {
  position: relative;
  display: inline-flex; align-items: center;
}
.search input {
  padding: 7px 12px 7px 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  width: 240px;
}
.search::before {
  content: "⌕";
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  color: var(--muted); font-size: 14px;
}

/* 数据表格 */
.table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.table th, .table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.table th {
  font-weight: 600; color: var(--ink-soft);
  background: #faf7ee;
  position: sticky; top: 0;
  z-index: 1;
}
.table tr:hover td { background: #fdfbf3; }
.table .actions { text-align: right; white-space: nowrap; }
.empty {
  padding: 40px 0; text-align: center; color: var(--muted);
}

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 32px;
  transform: translateX(-50%) translateY(8px);
  background: #1f2937; color: #fff;
  padding: 10px 16px; border-radius: 8px;
  font-size: 13px;
  opacity: 0; pointer-events: none;
  transition: all .25s;
  z-index: 999;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #b91c1c; }
.toast.ok { background: #166534; }

/* Modal */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(15,23,42,.32);
  display: grid; place-items: center;
  z-index: 800;
  animation: fade .15s ease;
}
.modal {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(0,0,0,.18);
  width: min(560px, 92vw);
  max-height: 88vh;
  display: flex; flex-direction: column;
  overflow: hidden;
}
.modal.large { width: min(860px, 94vw); }
.modal .modal-head {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 600;
}
.modal .modal-body { padding: 18px; overflow: auto; }
.modal .modal-foot {
  padding: 12px 18px;
  border-top: 1px solid var(--line-soft);
  display: flex; gap: 8px; justify-content: flex-end;
  background: #fbfaf5;
}
@keyframes fade { from {opacity: 0} to {opacity: 1} }

.loading {
  padding: 60px 0;
  color: var(--muted);
  text-align: center;
}

/* ============ 工作台 ============ */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 20px;
}
.stat {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow);
}
.stat .label { font-size: 12px; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 600; margin-top: 4px; }
.stat .desc { font-size: 12px; color: var(--ink-soft); margin-top: 4px; }

/* ============ 患者档案/就诊 ============ */
.split {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
}
.patient-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.patient-card .name {
  font-size: 18px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.kv { display: grid; grid-template-columns: 70px 1fr; gap: 6px; font-size: 13px; }
.kv .k { color: var(--muted); }
.kv .v { color: var(--ink); white-space: pre-wrap; }

/* 时间线 */
.timeline {
  position: relative;
  padding-left: 18px;
}
.timeline::before {
  content: ''; position: absolute; left: 5px; top: 0; bottom: 0;
  width: 2px; background: var(--line);
}
.tl-item {
  position: relative; margin-bottom: 14px;
}
.tl-item::before {
  content: ''; position: absolute; left: -17px; top: 14px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}
.tl-item.active::before { background: var(--accent); }
.tl-card {
  background: #fff; border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px;
  cursor: pointer;
  transition: all .15s;
}
.tl-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.tl-card.active { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122,59,46,.12); }
.tl-card .top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px; gap: 8px; flex-wrap: wrap;
}
.tl-card .date { font-weight: 600; }
.tl-card .summary { color: var(--ink-soft); font-size: 13px; line-height: 1.5; }

/* 开方页 */
.rx-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 16px;
}
.rx-list .row {
  display: grid;
  grid-template-columns: 1fr 90px 110px 90px 28px;
  gap: 8px; align-items: center;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line-soft);
}
.rx-list .row .name { font-weight: 500; }
.rx-list .row .grams input { text-align: right; }
.rx-list .head {
  font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding: 6px 0;
}
.rx-list .total {
  display: flex; justify-content: flex-end; gap: 18px;
  padding-top: 12px;
  font-size: 14px;
  flex-wrap: wrap;
}
.rx-list .total b { color: var(--accent); font-size: 16px; }

/* 联想下拉 */
.combo {
  position: relative;
}
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  max-height: 280px; overflow: auto;
  z-index: 80;
  padding: 4px;
}
.combo-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
}
.combo-item:hover, .combo-item.hl {
  background: var(--accent-soft);
}
.combo-item .meta {
  font-size: 12px; color: var(--muted);
}
mark.hl {
  background: #fde68a; color: inherit; padding: 0 1px; border-radius: 2px;
}

/* tag chips for templates */
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  font-size: 12px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-soft);
  transition: all .15s;
  user-select: none;
  white-space: nowrap;
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chip.green { color: var(--accent-2); }
.chip.green:hover { border-color: var(--accent-2); background: #ecf6f1; }
.chip-group { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chip-group .group-label {
  font-size: 12px; color: var(--muted);
  padding: 4px 0; min-width: 56px;
}

/* 联想词折叠面板 */
.chips.picker { margin-top: 4px; }
.chips.picker > [data-hide] { display: none; }
.chips.picker.open > .chip[data-hide] { display: inline-flex; }
.chips.picker.open > .chip-group[data-hide] {
  display: flex;
  flex-basis: 100%;
  width: 100%;
}
.chip.toggle-btn {
  background: #fff7ed;
  color: #b45309;
  border-color: #fed7aa;
  font-weight: 500;
}
.chip.toggle-btn:hover {
  background: #ffedd5;
  border-color: #fdba74;
  color: #9a3412;
}
.chip.toggle-btn .caret { margin-left: 4px; opacity: .85; }

/* badge */
.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  background: #fff7ed; color: #b45309;
  border: 1px solid #fed7aa;
}

/* small links */
.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.link.danger-text { color: var(--danger); }

/* ============ 首字母索引 ============ */
.az-index {
  display: flex; flex-wrap: wrap; gap: 4px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line-soft);
  margin-bottom: 4px;
  position: sticky; top: 0; z-index: 5;
  background: #fff;
}
.az-index .az-item {
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  cursor: pointer;
  color: var(--ink-soft);
  background: #fff;
}
.az-index .az-item:hover {
  border-color: var(--accent); color: var(--accent);
}
.az-index .az-item.disabled {
  opacity: .35; pointer-events: none;
}
.az-section {
  margin-top: 8px;
}
.az-section h3 {
  margin: 16px 0 4px;
  font-size: 14px; color: var(--accent);
  border-left: 3px solid var(--accent);
  padding-left: 8px;
}

/* 中药库：桌面表格 / 手机卡片（避免窄屏十一列表格溢出） */
.herbs-desktop-only { display: block; }
.herbs-mobile-only { display: none; }
.herb-cards {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.herb-card {
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fffdfa;
  overflow: hidden;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.herb-card-head { margin-bottom: 10px; }
.herb-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.35;
}
.herb-card-alias {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.4;
}
.herb-card-meta {
  margin: 0;
  display: grid;
  grid-template-columns: minmax(68px, auto) 1fr;
  gap: 8px 12px;
  font-size: 13px;
  color: var(--ink-soft);
}
.herb-card-meta dt {
  margin: 0;
  color: var(--muted);
  font-weight: 500;
}
.herb-card-meta dd {
  margin: 0;
  min-width: 0;
}
.herb-card-func {
  color: #475569;
  line-height: 1.55;
}
.herb-card-actions {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--line-soft);
  display: flex;
  justify-content: flex-end;
  gap: 18px;
  font-size: 13px;
}

/* ============ 底部固定操作栏 ============ */
.action-bar {
  position: fixed;
  left: 220px;
  right: 0;
  bottom: 0;
  height: var(--sticky-bar-h);
  background: rgba(255,255,255,.96);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
  gap: 12px;
  z-index: 70;
  box-shadow: 0 -4px 20px rgba(15,23,42,.06);
}
.action-bar .total {
  display: flex; gap: 18px; align-items: center;
  font-size: 14px;
}
.action-bar .total b { color: var(--accent); font-size: 18px; }
.action-bar .total .small { color: var(--muted); font-size: 12px; }
.action-bar .actions { display: flex; gap: 8px; align-items: center; }
.action-bar .draft-status {
  font-size: 12px; color: var(--muted); margin-right: 6px;
}
.action-bar .draft-status.saved { color: var(--ok); }
.action-bar .draft-status.saving { color: var(--warning); }

@media (max-width: 800px) {
  .action-bar {
    left: 0;
    padding: 0 12px;
    height: auto;
    flex-wrap: wrap;
    padding-top: 8px; padding-bottom: 8px;
  }
  .action-bar .total { gap: 10px; flex-wrap: wrap; }
  .action-bar .total b { font-size: 16px; }
}
.has-action-bar .main { padding-bottom: calc(var(--sticky-bar-h) + 60px); }

/* ============ 处方打印 ============ */
@media print {
  body * { visibility: hidden; }
  #print-area, #print-area * { visibility: visible; }
  #print-area {
    position: absolute; left: 0; top: 0;
    width: 100%; padding: 12px;
    background: #fff;
  }
  .sidebar, .toolbar, .modal-foot, .menu-btn,
  .action-bar, .no-print { display: none !important; }
  @page { margin: 12mm 14mm; }
}
.print-sheet {
  background: #fff;
  padding: 28px 32px;
  max-width: 720px;
  margin: 0 auto;
  font-family: "STSong", "SimSun", "Songti SC", serif;
  color: #111;
  line-height: 1.7;
}
.print-sheet h1 {
  text-align: center; font-size: 22px;
  letter-spacing: 4px;
  margin: 0 0 6px;
  font-weight: 600;
}
.print-sheet .clinic-sub {
  text-align: center; font-size: 12px; color: #555;
  margin-bottom: 14px;
  border-bottom: 2px solid #333;
  padding-bottom: 10px;
}
.print-sheet .info-row {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px 16px;
  font-size: 13px; padding: 8px 0;
  border-bottom: 1px solid #999;
}
.print-sheet .rx-mark {
  font-size: 28px; font-weight: 700; margin: 12px 0 6px;
}
.print-sheet .herbs {
  font-size: 15px;
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 6px 16px;
  margin: 8px 0 16px;
}
.print-sheet .meta {
  border-top: 1px dashed #888;
  padding-top: 8px;
  font-size: 13px;
}
.print-sheet .signature {
  margin-top: 28px; display: flex; justify-content: space-between;
  font-size: 13px;
}

/* ============ 医院常用样式处方笺 ============ */
.rx-print {
  background: #fff;
  padding: 20px 28px 26px;
  max-width: 760px;
  margin: 0 auto;
  font-family: "STSong", "SimSun", "Songti SC", serif;
  color: #111;
  line-height: 1.6;
  font-size: 13px;
}
.rx-print .rx-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 2px solid #111;
  padding-bottom: 8px;
}
.rx-print .clinic-name {
  font-size: 22px; font-weight: 700; letter-spacing: 2px;
}
.rx-print .clinic-meta {
  font-size: 12px; color: #444; margin-top: 4px;
}
.rx-print .rx-no {
  text-align: right; font-size: 13px;
}
.rx-print .rx-no .num {
  font-weight: 700; font-size: 15px; margin-top: 4px;
}
.rx-print h1 {
  text-align: center;
  font-size: 22px;
  letter-spacing: 6px;
  font-weight: 600;
  margin: 14px 0 10px;
}
.rx-print .rx-info {
  width: 100%;
  border-collapse: collapse;
}
.rx-print .rx-info td {
  padding: 6px 8px;
  border: 1px solid #999;
  font-size: 13px;
  vertical-align: middle;
}
.rx-print .rx-info b {
  color: #444; margin-right: 6px; font-weight: 600;
}
.rx-print .rx-rx {
  margin: 12px 0 8px;
  border-left: 4px solid #111;
  padding: 6px 14px 10px;
}
.rx-print .rx-mark {
  font-size: 24px; font-weight: 700; margin-bottom: 6px;
}
.rx-print .rx-mark sub { font-size: 14px; }
.rx-print .formula-name {
  font-size: 16px; font-weight: 600; margin-left: 14px;
}
.rx-print .herbs {
  margin: 8px 0 10px 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px 18px;
  list-style-position: inside;
  font-size: 14px;
}
.rx-print .herbs li {
  white-space: nowrap;
}
.rx-print .herbs .grams { margin-left: 4px; }
.rx-print .herbs .note { color: #555; margin-left: 2px; }
.rx-print .rx-usage {
  margin-top: 6px; padding-top: 6px;
  border-top: 1px dashed #888;
  font-size: 13px;
}
.rx-print .rx-amount {
  display: flex; gap: 18px; align-items: center;
  border-top: 1px solid #999;
  border-bottom: 1px solid #999;
  padding: 6px 4px;
  font-size: 13px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.rx-print .rx-sign {
  width: 100%;
  border-collapse: collapse;
}
.rx-print .rx-sign td {
  border: 1px solid #999;
  padding: 8px 10px;
  font-size: 13px;
}
.rx-print .rx-sign-simple {
  border-top: 1px solid #999;
  border-bottom: 1px solid #999;
  padding: 10px 4px;
  font-size: 13px;
  display: flex; justify-content: space-between; gap: 16px;
  flex-wrap: wrap;
}
.rx-print .rx-sign-simple .line {
  display: inline-block; min-width: 110px;
  border-bottom: 1px solid #444; padding: 0 6px;
}
.rx-print .rx-clinical {
  border: 1px solid #999; border-top: none;
  padding: 8px 12px;
  font-size: 13px; line-height: 1.7;
}
.rx-print .rx-clinical .row {
  padding: 2px 0;
}
.rx-print .rx-clinical .row b {
  display: inline-block;
  min-width: 70px;
  color: #333;
}
.rx-print .rx-clinical .four-diag {
  display: flex; flex-wrap: wrap; gap: 0 18px;
  border-top: 1px dashed #999;
  border-bottom: 1px dashed #999;
  padding: 6px 0; margin: 6px 0;
}
.rx-print .rx-clinical .four-diag span i {
  font-style: normal; font-weight: 700; margin-right: 4px;
  color: #444;
}
.rx-print .rx-clinical .diag-line {
  font-size: 14px;
  border-top: 1px dashed #999;
  padding-top: 6px; margin-top: 4px;
}
.rx-print .rx-clinical .diag-line span { font-weight: 600; }
.rx-print .rx-clinical .diag-line .muted { color: #666; font-weight: normal; margin-left: 6px; }
.rx-print .rx-foot {
  display: flex; justify-content: space-between;
  margin-top: 10px;
  font-size: 11px; color: #555;
}
