/* ============ 早安益堂 HIS 系统 - 全局样式 ============ */
:root {
  --primary: #2e8b57;
  --primary-dark: #256b45;
  --primary-light: #e8f5ee;
  --danger: #e74c3c;
  --warning: #f39c12;
  --info: #3498db;
  --success: #27ae60;
  --text: #333;
  --text-light: #777;
  --border: #e5e5e5;
  --bg: #f5f6f8;
  --white: #fff;
  --radius: 8px;
  --sidebar-w: 220px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: "Microsoft YaHei", "PingFang SC", sans-serif; color: var(--text); background: var(--bg); font-size: 14px; }
.hidden { display: none !important; }
a { text-decoration: none; color: var(--primary); }

/* ============ 登录页 ============ */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, #2e8b57 0%, #1a5c38 100%); }
.login-box { background: var(--white); border-radius: 12px; padding: 40px 48px; width: 400px; box-shadow: 0 12px 40px rgba(0,0,0,.2); text-align: center; }
.login-logo { font-size: 48px; }
/* 品牌标识方块：标了 data-brand-mark 的节点由 common.js 注入租户 LOGO / 文字标识 */
.login-logo[data-brand-mark] {
  width: 64px; height: 64px; margin: 0 auto 12px;
  border-radius: 16px; background: #fff; color: var(--primary);
  font-size: 34px; font-weight: 800; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .14);
  overflow: hidden;
}
.brand-logo-cn img { border-radius: 4px; }
.login-box h1 { font-size: 22px; margin: 10px 0 4px; color: var(--primary); }
.login-sub { color: var(--text-light); margin-bottom: 28px; }
.login-box .form-group { margin-bottom: 16px; text-align: left; }
.login-box input { width: 100%; padding: 11px 14px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; outline: none; }
.login-box input:focus { border-color: var(--primary); }
.login-error { color: var(--danger); margin-top: 12px; min-height: 18px; font-size: 13px; }

/* ============ 主框架（顶部一级导航 + 左侧子菜单 + 右侧内容区） ============ */
.app { display: flex; flex-direction: column; min-height: 100vh; background: var(--bg); }

/* 顶部导航 */
.app-header {
  height: 52px;
  background: #3b82f6;
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 12px;
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
}
.app-brand { display: flex; align-items: center; gap: 10px; min-width: 220px; flex-shrink: 0; }
.brand-logo-box { display: flex; align-items: center; gap: 8px; }
.brand-logo-cn {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  background: #fff; color: #2b8a5e;
  font-size: 18px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.18);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-title { font-size: 14px; font-weight: 800; letter-spacing: .3px; max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.brand-sub { font-size: 10px; color: rgba(255,255,255,.75); transform: scale(.95); transform-origin: left center; }
.brand-divider { width: 1px; height: 22px; background: rgba(255,255,255,.35); flex-shrink: 0; }
/* clinic-name 现在只承担"身份标签"角色，避免再显示全名跟 brand-title 撞 */
.app-clinic { font-size: 12px; font-weight: 500; opacity: .9; max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-top-nav { flex: 1; display: flex; align-items: center; justify-content: flex-start; gap: 2px; overflow-x: auto; min-width: 0; }
.app-top-nav::-webkit-scrollbar { display: none; }
.top-nav-item {
  display: flex; align-items: center; justify-content: center;
  min-width: 48px; padding: 0 10px; height: 32px; border-radius: 6px; cursor: pointer;
  color: rgba(255,255,255,.9); font-size: 13px; transition: all .15s; white-space: nowrap; flex-shrink: 0;
}
.top-nav-item:hover { background: rgba(255,255,255,.12); color: #fff; }
.top-nav-item.active { background: rgba(255,255,255,.22); color: #fff; font-weight: 500; }
.app-header-right { display: flex; align-items: center; gap: 12px; font-size: 13px; flex-shrink: 0; }
.header-date { color: rgba(255,255,255,.7); font-size: 12px; margin-right: 2px; white-space: nowrap; }
.header-link { color: rgba(255,255,255,.85); cursor: pointer; transition: color .15s; }
.header-link:hover { color: #fff; }
.header-user { display: flex; align-items: center; gap: 7px; }
.header-user .avatar { width: 28px; height: 28px; font-size: 13px; background: rgba(255,255,255,.2); }
.header-user .header-username { color: #fff; font-size: 13px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-header-right .btn-logout { background: none; border: none; color: rgba(255,255,255,.85); font-size: 18px; cursor: pointer; }
.app-header-right .btn-logout:hover { color: #fff; }

/* 主体 */
.app-body { display: flex; flex: 1; margin-top: 52px; min-height: calc(100vh - 52px); }
.app-sub-sidebar {
  width: 200px;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 52px; bottom: 0; left: 0;
  z-index: 90;
}
.sub-nav { flex: 1; overflow-y: auto; padding: 8px 0; }
.sub-nav::-webkit-scrollbar { width: 4px; }
.sub-nav::-webkit-scrollbar-thumb { background: rgba(0,0,0,.12); border-radius: 2px; }
.sub-nav-title {
  padding: 16px 20px 8px;
  font-size: 13px; font-weight: bold; color: var(--text);
}
.sub-nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; margin: 2px 10px;
  border-radius: 6px;
  color: var(--text-light); cursor: pointer; font-size: 14px;
  transition: all .15s;
}
.sub-nav-item:hover { background: #f4f6f8; color: var(--text); }
.sub-nav-item.active { background: var(--primary-light); color: var(--primary); font-weight: bold; }
.sub-nav-icon { width: 20px; text-align: center; }

.app-main { flex: 1; margin-left: 200px; display: flex; flex-direction: column; min-height: calc(100vh - 52px); }
.app-main-header {
  height: 48px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  position: sticky; top: 52px; z-index: 80;
}
.app-main-header .breadcrumb { font-size: 16px; font-weight: bold; color: var(--text); }
.content { padding: 20px; flex: 1; }

/* 旧侧边栏兼容（保留以支持未改动的 print/组件样式引用，实际 DOM 已不用） */
.sidebar { width: var(--sidebar-w); background: #22303f; color: #cfd8e3; display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0; z-index: 100; transition: transform .2s; }
.sidebar-header { display: flex; align-items: center; gap: 10px; padding: 18px 20px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo { font-size: 24px; }
.sidebar-title { font-size: 16px; font-weight: bold; color: #fff; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 10px 0; }
.nav-group-title { padding: 14px 20px 6px; font-size: 12px; color: #7a8a9c; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 10px 20px; color: #cfd8e3; cursor: pointer; border-left: 3px solid transparent; font-size: 14px; }
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: rgba(46,139,87,.25); color: #fff; border-left-color: var(--primary); }
.nav-item .nav-icon { width: 20px; text-align: center; }
.sidebar-footer { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; display: flex; flex-direction: column; min-height: 100vh; transition: margin-left .2s; }
.topbar { height: 56px; background: var(--white); border-bottom: 1px solid var(--border); display: flex; align-items: center; padding: 0 20px; gap: 16px; position: sticky; top: 0; z-index: 90; }
.btn-toggle { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-light); }
.topbar-right { display: flex; align-items: center; gap: 16px; color: var(--text-light); font-size: 13px; }
.clinic-name { font-weight: bold; color: var(--text); }

/* ============ 通用组件 ============ */
/* 卡片 */
.card { background: var(--white); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.card-title { font-size: 15px; font-weight: bold; margin-bottom: 16px; display: flex; align-items: center; justify-content: space-between; }

/* 按钮 */
.btn { display: inline-block; padding: 8px 18px; border: none; border-radius: var(--radius); cursor: pointer; font-size: 14px; transition: all .15s; background: var(--border); color: var(--text); }
.btn:hover { opacity: .85; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-block { width: 100%; display: block; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

/* 表单 */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-light); }
.form-group label .req { color: var(--danger); margin-left: 2px; }
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; outline: none; font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--primary); }
.form-group textarea { resize: vertical; min-height: 70px; }
.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

/* 搜索栏 */
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; align-items: center; }
.search-bar input, .search-bar select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; outline: none; }
.search-bar input { width: 200px; }
.search-bar input:focus, .search-bar select:focus { border-color: var(--primary); }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.table th { text-align: left; padding: 10px 12px; background: #f9fafb; color: var(--text-light); font-weight: bold; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; vertical-align: middle; }
table.table tr:hover td { background: #fafbfc; }
.table-empty { text-align: center; color: var(--text-light); padding: 40px 0; }
.table-actions .btn { margin-right: 6px; margin-bottom: 4px; }

/* 状态标签 */
.tag { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 12px; }
.tag-success { background: #e8f8f0; color: var(--success); }
.tag-warning { background: #fef5e7; color: var(--warning); }
.tag-danger { background: #fdedec; color: var(--danger); }
.tag-info { background: #ebf5fb; color: var(--info); }
.tag-gray { background: #f0f0f0; color: #999; }
.tag-primary { background: var(--primary-light); color: var(--primary); }

/* 分页 */
.pagination { display: flex; align-items: center; justify-content: space-between; margin-top: 16px; font-size: 13px; color: var(--text-light); }
.pagination .pages { display: flex; gap: 6px; }
.pagination button { padding: 5px 12px; border: 1px solid var(--border); background: var(--white); border-radius: 6px; cursor: pointer; font-size: 13px; }
.pagination button:hover:not([disabled]) { border-color: var(--primary); color: var(--primary); }
.pagination button[disabled] { opacity: .5; cursor: not-allowed; }
.pagination button.current { background: var(--primary); color: #fff; border-color: var(--primary); }

/* 工作台 */
.db-welcome { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; }
.db-welcome-greet { font-size: 18px; font-weight: bold; margin-bottom: 4px; }
.db-welcome-sub { color: var(--text-light); font-size: 13px; }
.db-overview-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.db-overview-card { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); padding: 18px; display: flex; align-items: center; gap: 16px; }
.db-overview-card.customer { border-left: 4px solid #3b82f6; }
.db-overview-card.income { border-left: 4px solid #f39c12; }
.db-overview-icon { width: 48px; height: 48px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.db-overview-card.customer .db-overview-icon { background: #ebf5ff; }
.db-overview-card.income .db-overview-icon { background: #fef5e7; }
.db-overview-title { font-size: 16px; font-weight: bold; margin-bottom: 10px; }
.db-overview-items { display: flex; gap: 24px; }
.db-overview-items > div { display: flex; flex-direction: column; }
.db-overview-num { font-size: 22px; font-weight: bold; line-height: 1.2; }
.db-overview-unit { font-size: 12px; color: var(--text-light); margin-top: 2px; }

/* 统计卡片 */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.stat-card { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.05); }
.stat-card .stat-label { color: var(--text-light); font-size: 13px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 26px; font-weight: bold; }
.stat-card .stat-value.green { color: var(--primary); }
.stat-card .stat-value.red { color: var(--danger); }
.stat-card .stat-value.blue { color: var(--info); }
.stat-card .stat-value.orange { color: var(--warning); }
.stat-card .stat-sub { margin-top: 6px; font-size: 12px; color: var(--text-light); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200; display: flex; align-items: center; justify-content: center; }
.modal { background: var(--white); border-radius: 10px; width: 560px; max-width: 94vw; max-height: 88vh; display: flex; flex-direction: column; box-shadow: 0 12px 40px rgba(0,0,0,.2); }
.modal.modal-lg { width: 860px; }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--border); font-size: 16px; font-weight: bold; }
.modal-close { background: none; border: none; font-size: 22px; color: var(--text-light); cursor: pointer; line-height: 1; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px; overflow-y: auto; }
/* 弹窗底部操作区：新弹窗把主按钮放这里；存量弹窗仍放在 body 内，不受影响。
   :empty 保证没有按钮时不显示多余分隔线。 */
.modal-footer {
  padding: 12px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-footer:empty { display: none; }

/* 消息提示 */
.toast-wrap { position: fixed; top: 70px; right: 20px; z-index: 300; display: flex; flex-direction: column; gap: 10px; }
.toast { padding: 12px 20px; border-radius: 8px; color: #fff; font-size: 14px; box-shadow: 0 4px 12px rgba(0,0,0,.15); animation: slideIn .25s; min-width: 200px; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: none; opacity: 1; } }

/* 详情行 */
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px 24px; }
.detail-item .d-label { color: var(--text-light); font-size: 12px; margin-bottom: 2px; }
.detail-item .d-value { font-size: 14px; }

/* 简单图表条 */
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding-top: 10px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 0; }
.bar-col .bar { width: 70%; background: linear-gradient(to top, var(--primary), #52b788); border-radius: 4px 4px 0 0; min-height: 2px; transition: height .3s; }
.bar-col .bar-val { font-size: 11px; color: var(--text-light); white-space: nowrap; }
.bar-col .bar-label { font-size: 11px; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* 打印 */
@media print {
  .app-header, .app-sub-sidebar, .app-main-header, .search-bar, .table-actions, .pagination, #toast-wrap { display: none !important; }
  .app-main { margin-left: 0; }
  .content { padding: 0; }
}

/* 响应式 */
@media (max-width: 768px) {
  .app-sub-sidebar { transform: translateX(-100%); }
  .app-main { margin-left: 0; }
  .form-row { flex-direction: column; gap: 0; }
  .detail-grid { grid-template-columns: 1fr; }
}

/* ============ 小步云管家式页面内布局 ============ */
.xb-page { display: flex; min-height: calc(100vh - 100px); }
/* [2026-09-14] 开方页分区滚动（对齐若邻「一屏完成接诊」形态）。
   .xb-page 原先只有 min-height，内容一长整页就滚动 —— 于是左侧候诊队列和
   右侧处方笺都会被滚出视口，医生开着开着就看不到自己的方子了。
   改成固定高度后，.xb-page-main 本来就写好的 overflow-y:auto 才真正生效：
   中栏独立滚动，两侧常驻。
   注意 flex item 默认 min-height:auto 会阻止内部滚动，必须显式归零。 */
.xb-page.xb-page-fixed { height: calc(100vh - 96px); min-height: 0; }
.xb-page.xb-page-fixed .xb-page-content { min-height: 0; }
.xb-page.xb-page-fixed .xb-page-main { min-height: 0; }
.xb-page.xb-page-fixed .xb-right-panel { min-height: 0; }
.xb-page-sidebar {
  width: 240px; background: var(--white); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.xb-page-content { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.xb-page-main { flex: 1; padding: 16px 20px; overflow-y: auto; }
.xb-page-right {
  width: 260px; background: var(--white); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}

/* 页内工具栏 */
.xb-main-header {
  height: 50px; background: var(--white); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 20px; gap: 12px;
}
.xb-main-title { font-size: 15px; font-weight: bold; flex: 1; }
.xb-main-actions { display: flex; align-items: center; gap: 8px; }

/* 状态标签页 */
.xb-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); padding: 0 20px; background: var(--white); }
.xb-tab { padding: 10px 16px; cursor: pointer; font-size: 14px; color: var(--text-light); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.xb-tab:hover { color: var(--text); }
.xb-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: bold; }
.xb-tab .num { font-size: 12px; margin-left: 4px; color: var(--danger); }

/* 搜索+按钮区 */
.xb-searchbar { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.xb-searchbar input { width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; margin-bottom: 10px; }
.xb-searchbar .btn-block { text-align: center; }

/* 空态 */
.xb-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--text-light); padding: 60px 20px; }
.xb-empty-icon { font-size: 64px; opacity: .25; margin-bottom: 12px; }

/* 小工具 */
.xb-tools { padding: 14px 16px; border-top: 1px solid var(--border); }
.xb-tools-title { font-size: 13px; font-weight: bold; margin-bottom: 10px; }
.xb-tool-item { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; font-size: 13px; color: var(--text-light); cursor: pointer; }
.xb-tool-item:hover { color: var(--primary); }
.xb-tool-item .arrow { color: #bbb; }

/* 月历 */
.xb-calendar { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.xb-cal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 14px; }
.xb-cal-header button { background: none; border: none; cursor: pointer; color: var(--text-light); font-size: 16px; }
.xb-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.xb-cal-weekday { font-size: 12px; color: var(--text-light); padding: 6px 0; }
.xb-cal-day { padding: 6px 0; font-size: 13px; border-radius: 6px; cursor: pointer; }
.xb-cal-day:hover { background: #f4f6f8; }
.xb-cal-day.today { background: var(--primary); color: #fff; }
.xb-cal-day.selected { background: var(--primary-light); color: var(--primary); font-weight: bold; }
.xb-cal-day.other { color: #ccc; }

/* 医生/患者卡片列表 */
.xb-list { overflow-y: auto; flex: 1; }
.xb-list-card {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid #f5f5f5; cursor: pointer;
}
.xb-list-card:hover { background: #fafbfc; }
.xb-list-card.active { background: #ebf5ff; border-left: 3px solid var(--info); }
.xb-list-avatar { width: 36px; height: 36px; border-radius: 50%; background: #e8f0fe; color: var(--info); display: flex; align-items: center; justify-content: center; font-size: 14px; flex-shrink: 0; }
.xb-list-info { flex: 1; min-width: 0; }
.xb-list-name { font-size: 14px; font-weight: bold; margin-bottom: 2px; }
.xb-list-meta { font-size: 12px; color: var(--text-light); }

/* 统计看板 */
.db-period-tabs { display: flex; gap: 16px; margin-left: 16px; }
.db-period-tab { font-size: 14px; color: var(--text-light); cursor: pointer; padding-bottom: 2px; }
.db-period-tab:hover { color: var(--text); }
.db-period-tab.active { color: var(--primary); font-weight: bold; border-bottom: 2px solid var(--primary); }

/* 卡片式指标 */
.xb-kpi-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 16px; margin-bottom: 16px; }
.xb-kpi-card { background: var(--white); border-radius: var(--radius); padding: 16px; border: 1px solid var(--border); }
.xb-kpi-label { font-size: 13px; color: var(--text-light); margin-bottom: 6px; }
.xb-kpi-value { font-size: 24px; font-weight: bold; }
.xb-kpi-sub { font-size: 12px; color: var(--text-light); margin-top: 4px; }

/* 表单区块（病历样式） */
.xb-form-block { background: var(--white); border-radius: var(--radius); border: 1px solid var(--border); margin-bottom: 16px; }
.xb-form-block-header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.xb-form-block-title { font-size: 14px; font-weight: bold; }
.xb-form-block-actions { display: flex; gap: 8px; }
.xb-form-block-body { padding: 16px; }
.xb-form-row { display: flex; gap: 0; border-bottom: 1px solid #f5f5f5; }
.xb-form-row:last-child { border-bottom: none; }
.xb-form-cell { flex: 1; display: flex; border-right: 1px solid #f5f5f5; }
.xb-form-cell:last-child { border-right: none; }
.xb-form-cell label { width: 80px; padding: 12px 14px; background: #fafbfc; color: var(--text-light); font-size: 13px; border-right: 1px solid #f5f5f5; display: flex; align-items: center; }
.xb-form-cell label .req { color: var(--danger); margin-left: 2px; }
.xb-form-cell input, .xb-form-cell textarea { flex: 1; border: none; padding: 10px 14px; font-size: 14px; outline: none; background: transparent; min-height: 42px; }
.xb-form-cell textarea { resize: vertical; min-height: 60px; }

/* 右侧边栏 */
.xb-right-tabs { display: flex; border-bottom: 1px solid var(--border); }
.xb-right-tab { flex: 1; text-align: center; padding: 12px; cursor: pointer; font-size: 14px; color: var(--text-light); }
.xb-right-tab.active { color: var(--primary); font-weight: bold; border-bottom: 2px solid var(--primary); }
.xb-right-panel { flex: 1; overflow-y: auto; padding: 12px; }

/* 筛选面板 */
.xb-filter-panel { padding: 16px; }
.xb-filter-title { font-size: 13px; font-weight: bold; margin-bottom: 14px; }
.xb-filter-group { margin-bottom: 14px; }
.xb-filter-group label { display: block; font-size: 12px; color: var(--text-light); margin-bottom: 6px; }
.xb-filter-range { display: flex; align-items: center; gap: 6px; }
.xb-filter-range input { flex: 1; padding: 6px 8px; border: 1px solid var(--border); border-radius: 4px; font-size: 13px; }
.xb-filter-btns { display: flex; gap: 8px; margin-top: 16px; }

/* 页面内左侧竖向导航（药房等模块） */
.xb-nav-item { padding: 12px 16px; font-size: 14px; color: var(--text); cursor: pointer; border-left: 3px solid transparent; display: flex; align-items: center; gap: 8px; }
.xb-nav-item:hover { background: #f5f7fa; }
.xb-nav-item.active { background: var(--primary-light, #e8f5ef); color: var(--primary); border-left-color: var(--primary); font-weight: bold; }

/* ============ 工作台（小步云式布局） ============ */
.db-shell { display: flex; gap: 16px; align-items: flex-start; }
.db-main { flex: 1; min-width: 0; }
.db-side { width: 260px; flex-shrink: 0; }
.db-side .card { margin-bottom: 16px; }

/* 顶部搜索 + 诊所信息 */
.db-search-wrap { background: var(--white); border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--border); margin-bottom: 16px; }
.db-search-box { display: flex; gap: 8px; align-items: center; }
.db-search-box input { flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 4px; font-size: 14px; outline: none; }
.db-search-box input:focus { border-color: var(--primary); }
.db-search-box button { background: #409eff; color: var(--white); border: none; padding: 10px 18px; border-radius: 4px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.db-search-box button:hover { background: #66b1ff; }
.db-search-tips { margin-top: 8px; font-size: 12px; color: #909399; }
.db-clinic-info { background: var(--white); border-radius: var(--radius); padding: 16px 18px; border: 1px solid var(--border); margin-bottom: 16px; }
.db-clinic-title { font-size: 16px; font-weight: bold; margin-bottom: 10px; }
.db-clinic-row { font-size: 13px; line-height: 1.9; color: var(--text); display: flex; justify-content: space-between; align-items: center; }
.db-version-tag { background: var(--primary); color: var(--white); padding: 2px 8px; border-radius: 3px; font-size: 12px; }

/* 库存 + 收入统计卡片 */
.db-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.db-stat-card { background: var(--white); border-radius: var(--radius); padding: 18px 20px; border: 1px solid var(--border); display: flex; align-items: center; gap: 16px; cursor: pointer; transition: transform .15s, box-shadow .15s; }
.db-stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0,0,0,.08); }
.db-stat-icon { width: 48px; height: 48px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 24px; flex-shrink: 0; }
.db-stat-inventory .db-stat-icon { background: #f0f9eb; }
.db-stat-income .db-stat-icon { background: #fef0e6; }
.db-stat-body { flex: 1; min-width: 0; }
.db-stat-title { font-size: 14px; color: var(--text-light); margin-bottom: 6px; }
.db-stat-num { font-size: 28px; font-weight: bold; color: var(--primary); margin-bottom: 6px; line-height: 1; }
.db-stat-tags { font-size: 12px; color: var(--text-light); display: flex; gap: 12px; flex-wrap: wrap; }
.db-stat-tags b { color: var(--text); font-size: 13px; }

/* 今日看诊 + 排班表 */
#db-today-wrap .table-wrap, #db-schedule-wrap .table-wrap { max-height: 480px; overflow: auto; }
.db-schedule-table th { text-align: center; }
.db-schedule-table td { text-align: center; vertical-align: middle; }

.db-schedule-week { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--text-light); }
.db-week-btn { background: var(--white); border: 1px solid var(--border); padding: 4px 12px; cursor: pointer; border-radius: 3px; font-size: 12px; }
.db-week-btn:hover { background: #f5f7fa; }
.db-week-range { font-weight: bold; color: var(--text); font-size: 13px; padding: 0 8px; }
.db-action-link { font-size: 13px; color: var(--primary); margin-left: auto; }

/* 右侧一对一服务 / 微信公众号 */
.db-service-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f5f5f5; }
.db-service-row:last-child { border-bottom: none; }
.db-service-icon { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 22px; flex-shrink: 0; }
.db-service-title { font-size: 14px; font-weight: bold; margin-bottom: 4px; }
.db-service-sub { font-size: 12px; color: var(--text-light); }

/* ============================================================
   2026-09-10 UI 体验增强（设计系统 / 表格 / 反馈 / 库存专项）
   原则：新增为主、覆盖为辅。可能影响存量页面的效果（如粘性表头）
   一律做成按需启用的 class，不全局强制。
   ============================================================ */

/* ---------- 设计令牌扩充 ---------- */
:root {
  --gray-50: #fafbfc;
  --gray-100: #f2f4f7;
  --gray-200: #eceff3;
  --gray-300: #e0e3e8;
  --text-mute: #9aa2ad;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, .08);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, .16);
  --radius-sm: 6px;
  --radius-lg: 12px;
  --ease: cubic-bezier(.4, 0, .2, 1);
  --dur: .18s;
}

/* ---------- 卡片 ---------- */
.card { border: 1px solid var(--border); transition: box-shadow var(--dur) var(--ease); }
.card:hover { box-shadow: var(--shadow-md); }
.card-title { padding-bottom: 12px; border-bottom: 1px solid #f0f0f0; margin-bottom: 16px; }
.card-title .card-sub { font-size: 12px; color: var(--text-mute); font-weight: normal; margin-left: 8px; }

/* ---------- 表格体验 ---------- */
table.table tbody tr { transition: background var(--dur) var(--ease); }
table.table tbody tr:nth-child(even) td { background: var(--gray-50); }
table.table tbody tr:hover > td { background: #eff8f3 !important; }
table.table td.num, table.table th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* 粘性表头：需页面显式加 .table-sticky 且容器可滚动，避免影响存量页面 */
.table-sticky thead th {
  position: sticky; top: 0; z-index: 3;
  background: #f9fafb; box-shadow: inset 0 -1px 0 var(--border);
}
.table-wrap-scroll { max-height: 62vh; overflow: auto; }
.table-wrap-scroll::-webkit-scrollbar { width: 8px; height: 8px; }
.table-wrap-scroll::-webkit-scrollbar-thumb { background: #d5d9df; border-radius: 4px; }
.table-wrap-scroll::-webkit-scrollbar-thumb:hover { background: #b9bfc7; }

/* 预警行：库存低于预警线时整行淡黄底 */
table.table tbody tr.row-warning > td { background: #fffbf0 !important; }
table.table tbody tr.row-warning:hover > td { background: #fff6e3 !important; }

/* ---------- 空状态（比一行灰字更有引导性） ---------- */
.empty-state { text-align: center; padding: 52px 20px; color: var(--text-mute); }
.empty-state .empty-icon { font-size: 46px; line-height: 1; opacity: .32; margin-bottom: 14px; }
.empty-state .empty-title { font-size: 15px; color: var(--text); margin-bottom: 6px; font-weight: 600; }
.empty-state .empty-desc { font-size: 13px; margin-bottom: 18px; line-height: 1.6; }
/* 只有包了 .empty-state 才取消单元格内边距（由 empty-state 自己控制留白），
   否则纯文字的「暂无数据」会贴边 —— 存量页面大量使用 HIS.emptyRow() */
.table-empty:has(.empty-state) { padding: 0 !important; }

/* ---------- 骨架屏 ---------- */
.skeleton {
  background: linear-gradient(90deg, #f0f1f3 25%, #f7f8fa 37%, #f0f1f3 63%);
  background-size: 400% 100%;
  animation: skeleton-shimmer 1.4s ease infinite;
  border-radius: var(--radius-sm);
  display: inline-block;
}
@keyframes skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-row { height: 14px; margin: 10px 0; }

/* ---------- 按钮 loading（防重复提交） ---------- */
.btn.is-loading { position: relative; color: transparent !important; pointer-events: none; opacity: .8; }
.btn.is-loading::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid rgba(255, 255, 255, .5);
  border-top-color: #fff; border-radius: 50%;
  animation: btn-spin .6s linear infinite;
}
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn:not(.is-loading) { transition: all var(--dur) var(--ease); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------- Toast 升级（带图标 + 底部进度条） ---------- */
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: 380px; min-width: 220px;
  padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13.5px; line-height: 1.5;
  box-shadow: var(--shadow-md);
  animation: toast-in .28s var(--ease);
  position: relative; overflow: hidden;
}
.toast-icon { font-size: 15px; line-height: 1.4; flex-shrink: 0; }
.toast-msg { flex: 1; word-break: break-word; }
.toast-bar {
  position: absolute; left: 0; bottom: 0; height: 2px;
  background: rgba(255, 255, 255, .55);
  animation: toast-bar 2.6s linear forwards;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes toast-bar { from { width: 100%; } to { width: 0; } }

/* ---------- 确认弹窗（confirmAsync 用，替代原生 window.confirm） ---------- */
.confirm-mask {
  position: fixed; inset: 0; background: rgba(0, 0, 0, .42);
  z-index: 400; display: flex; align-items: center; justify-content: center;
  animation: fade-in .16s var(--ease);
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
.confirm-box {
  background: var(--white); border-radius: var(--radius-lg);
  width: 400px; max-width: 92vw; box-shadow: var(--shadow-lg);
  padding: 24px; animation: confirm-pop .2s var(--ease);
}
@keyframes confirm-pop {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.confirm-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.confirm-icon { font-size: 22px; }
.confirm-title { font-size: 16px; font-weight: 700; color: var(--text); }
.confirm-msg { font-size: 13.5px; color: #555; line-height: 1.7; margin-bottom: 22px; white-space: pre-wrap; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; }

/* ---------- 库存页专项 ---------- */

/* 类型切换分段器 */
.seg-group {
  display: inline-flex; background: var(--gray-100);
  padding: 4px; border-radius: 10px; gap: 2px; flex-wrap: wrap;
}
.seg-btn {
  border: none; background: transparent; padding: 7px 15px;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; color: var(--text-light);
  transition: all var(--dur) var(--ease);
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.seg-btn:hover { color: var(--text); background: rgba(255, 255, 255, .6); }
.seg-btn.active {
  background: var(--white); color: var(--primary);
  font-weight: 600; box-shadow: var(--shadow-sm);
}
.seg-count {
  background: var(--primary-light); color: var(--primary);
  padding: 1px 7px; border-radius: 10px; font-size: 11px; font-weight: 700;
}
.seg-btn.active .seg-count { background: var(--primary); color: #fff; }

/* 汇总卡片（带图标与副指标） */
.summary-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px;
  transition: all var(--dur) var(--ease); cursor: default;
}
.summary-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.sc-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.sc-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.sc-label { font-size: 13px; color: var(--text-light); font-weight: 600; }
.sc-value { font-size: 26px; font-weight: 800; line-height: 1.15; font-variant-numeric: tabular-nums; }
.sc-unit { font-size: 12px; color: var(--text-mute); font-weight: normal; margin-left: 3px; }
.sc-foot { display: flex; gap: 14px; margin-top: 12px; padding-top: 12px; border-top: 1px solid #f2f4f7; }
.sc-foot-item { font-size: 12px; color: var(--text-mute); }
.sc-foot-item b { color: var(--text); font-weight: 700; }
.sc-foot-item.warn b { color: var(--danger); }
.sc-foot-item.near b { color: var(--warning); }

/* 库存水位条 */
.stock-bar {
  position: relative; height: 6px; background: var(--gray-200);
  border-radius: 3px; overflow: hidden; min-width: 64px; margin-top: 4px;
}
.stock-bar-fill { height: 100%; border-radius: 3px; transition: width .35s var(--ease); }
.stock-bar-fill.ok { background: var(--success); }
.stock-bar-fill.low { background: var(--warning); }
.stock-bar-fill.out { background: var(--danger); }

/* 效期徽章 */
.expiry-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: var(--radius-sm);
  font-size: 12px; font-variant-numeric: tabular-nums;
}
.expiry-badge.safe { background: #e8f8f0; color: var(--success); }
.expiry-badge.near { background: #fef5e7; color: var(--warning); }
.expiry-badge.expired { background: #fdedec; color: var(--danger); }
.expiry-badge.none { background: #f2f4f7; color: var(--text-mute); }

/* 批次明细（展开行） */
.batch-panel { background: var(--gray-50); padding: 12px 16px; }
.batch-panel table { background: var(--white); }

/* 数字与金额强调 */
.num-strong { font-weight: 700; font-variant-numeric: tabular-nums; }
.money-strong { color: var(--primary); font-weight: 700; font-variant-numeric: tabular-nums; }
.text-mute { color: var(--text-mute); }

/* ---------- 表单校验 ---------- */
.form-group.has-error input,
.form-group.has-error select,
.form-group.has-error textarea { border-color: var(--danger); background: #fffafa; }
.field-error { color: var(--danger); font-size: 12px; margin-top: 5px; display: flex; align-items: center; gap: 4px; }
.field-tip { color: var(--text-mute); font-size: 12px; margin-top: 5px; }

/* ---------- 工具栏（筛选区 + 右侧操作） ---------- */
.toolbar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar .spacer { flex: 1; }
.toolbar input[type=text], .toolbar select {
  padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13px; outline: none;
  transition: border-color var(--dur) var(--ease);
}
.toolbar input[type=text]:focus, .toolbar select:focus { border-color: var(--primary); }

/* ════════════════════════════════════════════════════════════
   [2026-09-14] 开方区紧凑化 —— 对齐若邻/小步云等中医 SaaS 的通行形态
   背景：原实现每味药是一张 ~60px 高卡片 + 8px 间距，可视区仅 260px，
        一屏只看 4 味，20 味方要滚 5 屏。改为「一行一味」的表格形态后
        行高 36px、可视区 460px，一屏 13 味，列对齐后剂量可竖排扫读。
   兼容：行元素同时带 .cm-rx-card（旧选择器）与 .rx-row（新样式类），
        上层逻辑（汇总/校验/配伍高亮/回显）零改动。
   ════════════════════════════════════════════════════════════ */
.rx-list { border:1px solid #e8e8e8; border-radius:8px; overflow:hidden; background:#fff; }
.rx-head, .rx-row {
  display:grid;
  /* 药品名列封顶 380px：处方区在宽屏上可达 1150px，1fr 会让药名列撑到 600px+
     而右侧几列挤成一条，读起来很散。封顶后各列宽度接近，右侧自然留白。 */
  grid-template-columns: 34px minmax(150px,380px) 124px 76px 116px 116px 46px;
  align-items:center;
}
.rx-head { background:#f7f8fa; border-bottom:1px solid #ececec; height:30px; font-size:12px; color:#8a8f99; }
.rx-head > span { padding:0 6px; }
.rx-body { max-height:min(48vh, 460px); overflow-y:auto; }
.rx-row { min-height:36px; border-bottom:1px solid #f4f5f6; }
.rx-row:last-child { border-bottom:none; }
.rx-row:hover { background:#fafcff; }
.rx-row > * { padding:0 6px; min-width:0; }

.rx-c-no { font-size:12px; color:#b8bdc5; text-align:center; padding:0 2px; }
.rx-c-name { display:flex; align-items:baseline; gap:6px; overflow:hidden; }
.rx-c-name b { font-size:14px; font-weight:600; color:#222; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rx-c-name small { font-size:11px; color:#a8adb6; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rx-c-name .cm-rx-warn-badge { flex:0 0 auto; font-size:11px; font-weight:400; padding:1px 5px; border-radius:9px; white-space:nowrap; font-style:normal; }
.rx-c-dose { display:flex; align-items:center; gap:3px; }
.rx-c-pct, .rx-c-price { font-size:12px; color:#8a8f99; text-align:right; }
.rx-c-sum { font-size:13px; font-weight:600; color:#333; text-align:right; }
.rx-c-op { text-align:center; padding:0; }

.rx-grams {
  width:54px; height:26px; text-align:center; font-size:14px; font-weight:600; color:#222;
  border:1px solid #dfe3e8; border-radius:5px; padding:0 2px; background:#fff;
}
.rx-grams:focus { border-color:var(--primary); outline:none; box-shadow:0 0 0 2px rgba(59,130,246,.13); }
.rx-del { width:24px; height:24px; border:none; background:transparent; color:#c8ccd3; font-size:14px; line-height:1; cursor:pointer; border-radius:4px; }
.rx-del:hover { background:#fff1f0; color:#cf1322; }

/* 配伍警示：整行下方展开，不挤压药名列 */
.rx-row > .cm-rx-warn-detail { grid-column:1 / -1; padding:5px 10px 8px 36px; font-size:12px; line-height:1.6; white-space:pre-wrap; }
/* 配伍高亮用左侧色条，避免 border 改变行高造成列表抖动 */
.rx-row.rx-hit-danger { background:#fff2f0; box-shadow: inset 3px 0 0 #cf1322; }
.rx-row.rx-hit-warn { background:#fff7e6; box-shadow: inset 3px 0 0 #fa8c16; }
/* 重复添加已有药味时的闪烁定位（与配伍高亮区分开） */
.rx-row.rx-dup-flash { box-shadow: inset 3px 0 0 #faad14; animation: rxDupFlash .55s ease 2; }
@keyframes rxDupFlash { 0%,100% { background:#fffbe6; } 50% { background:#ffe58f; } }

/* 空态 */
.rx-empty { padding:26px 12px; text-align:center; color:#b0b5bd; font-size:13px; }

/* ── 右侧「处方笺」实时预览（对标若邻 Rp. 面板） ── */
.rxp { font-size:13px; }
.rxp-hd { display:flex; align-items:baseline; justify-content:space-between; margin-bottom:6px; }
.rxp-title { font-size:15px; font-weight:700; color:#1f6feb; letter-spacing:.5px; }
.rxp-cnt { font-size:11px; color:#9aa0a8; }
.rxp-grid { display:grid; grid-template-columns:1fr 1fr; gap:0 10px; border-top:1px dashed #dcdfe4; padding-top:8px; }
.rxp-item { display:flex; align-items:baseline; justify-content:space-between; gap:4px; padding:3px 0; border-bottom:1px dotted #f2f4f6; }
.rxp-item i { font-style:normal; color:#333; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rxp-item u { text-decoration:none; color:#c0392b; font-weight:600; white-space:nowrap; }
.rxp-foot { margin-top:10px; padding-top:8px; border-top:1px dashed #dcdfe4; font-size:12px; color:#666; line-height:1.9; }
.rxp-foot b { color:#c0392b; }
.rxp-empty { padding:28px 10px; text-align:center; color:#b0b5bd; font-size:12px; line-height:1.8; }
