:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #eff6ff;
  --success: #16a34a;
  --success-light: #f0fdf4;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #dc2626;
  --danger-light: #fef2f2;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(15,23,42,.04);
  --shadow: 0 4px 12px rgba(15,23,42,.08);
  --shadow-lg: 0 10px 30px rgba(15,23,42,.12);
  --sidebar-w: 220px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--gray-700);
  background: var(--gray-100);
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }

/* 登录页 */
.login-wrap {
  min-height: 100vh;
  display: flex;
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
}
.login-brand {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 60px;
  color: #fff;
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(6px);
}
.login-brand .logo-icon {
  width: 72px; height: 72px;
  border-radius: 18px;
  background: rgba(255,255,255,.15);
  display: flex; align-items: center; justify-content: center;
  font-size: 38px; margin-bottom: 24px;
}
.login-brand h1 { font-size: 42px; font-weight: 700; letter-spacing: 2px; margin-bottom: 14px; }
.login-brand p { font-size: 16px; line-height: 1.7; opacity: .9; max-width: 460px; margin-bottom: 36px; }
.login-features { list-style: none; }
.login-features li {
  display: flex; align-items: center; gap: 12px;
  font-size: 15px; margin-bottom: 16px; opacity: .95;
}
.login-features li i { font-size: 20px; }
.login-form-panel {
  width: 460px;
  min-width: 460px;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.login-box {
  width: 100%;
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 38px 40px;
  box-shadow: var(--shadow-lg);
}
.login-box h2 { font-size: 26px; color: var(--gray-800); margin-bottom: 4px; }
.login-box .sub { color: var(--gray-400); font-size: 14px; margin-bottom: 28px; }
.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: flex; align-items: center; gap: 8px;
}
.login-field { margin-bottom: 18px; }
.login-field label { display: block; font-size: 13px; color: var(--gray-500); margin-bottom: 6px; }
.login-field input {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: border-color .15s, box-shadow .15s;
}
.login-field input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 500;
  transition: background .15s;
}
.login-btn:hover { background: var(--primary-dark); }
.login-btn:disabled { opacity: .7; cursor: not-allowed; }
.demo-accounts {
  margin-top: 22px;
  padding: 14px 16px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--gray-500);
  line-height: 1.9;
}
.demo-accounts b { color: var(--gray-700); }

/* 布局 */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: var(--gray-900);
  color: var(--gray-300);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 10;
}
.sidebar .logo {
  padding: 20px 20px 18px;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.08);
  line-height: 1.3;
}
.sidebar .logo small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--gray-500);
  margin-top: 4px;
}
.sidebar .nav { padding: 10px 0; flex: 1; overflow-y: auto; }
.sidebar a.menu {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--gray-400);
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all .12s;
}
.sidebar a.menu i { font-size: 18px; }
.sidebar a.menu:hover { background: rgba(255,255,255,.04); color: #fff; }
.sidebar a.menu.active {
  background: rgba(37,99,235,.18);
  color: #fff;
  border-left-color: var(--primary);
}
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px;
  box-shadow: var(--shadow-sm);
  z-index: 5;
}
.topbar .page-title { font-size: 16px; font-weight: 600; color: var(--gray-800); display: flex; align-items: center; gap: 10px; }
.topbar .who { color: var(--gray-500); font-size: 13px; display: flex; align-items: center; gap: 18px; }
.topbar .who a { color: var(--gray-400); display: inline-flex; align-items: center; gap: 6px; }
.topbar .who a:hover { color: var(--danger); }
.content { padding: 22px 26px; flex: 1; overflow: auto; }

/* 卡片与标题 */
.card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
}
.card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 14px;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}
.card h3 i { color: var(--primary); }

/* 工具条 */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box i { position: absolute; left: 10px; color: var(--gray-400); font-size: 16px; }
.search-box input { padding-left: 32px; }

/* 表单元素 */
input, select, textarea {
  padding: 8px 12px;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--gray-700);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
input::placeholder, textarea::placeholder { color: var(--gray-400); }
select { min-height: 34px; }

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  transition: filter .12s, transform .05s;
}
.btn:hover { filter: brightness(.95); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .6; cursor: not-allowed; }
.btn.gray { background: var(--gray-200); color: var(--gray-600); }
.btn.gray:hover { background: var(--gray-300); }
.btn.green { background: var(--success); }
.btn.green:hover { filter: brightness(.95); }
.btn.red { background: var(--danger); }
.btn.red:hover { filter: brightness(.95); }
.btn.orange { background: var(--warning); color: #fff; }
.btn.orange:hover { filter: brightness(.95); }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn i { font-size: 15px; }

/* 表格 */
table.grid { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.grid th {
  background: var(--gray-50);
  color: var(--gray-600);
  padding: 11px 12px;
  text-align: left;
  font-weight: 600;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
table.grid td { padding: 10px 12px; border-bottom: 1px solid var(--gray-100); }
table.grid tr:last-child td { border-bottom: none; }
table.grid tr:hover td { background: var(--gray-50); }

/* 标签 */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  background: var(--primary-light);
  color: var(--primary);
  margin: 2px;
  font-weight: 500;
}
.tag.warn { background: var(--danger-light); color: var(--danger); }
.tag.ok { background: var(--success-light); color: var(--success); }
.tag.gray { background: var(--gray-100); color: var(--gray-500); }
.tag.orange { background: var(--warning-light); color: #b45309; }

/* 消息提示 */
.msg {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.msg.ok { background: var(--success-light); color: var(--success); }
.msg.err { background: var(--danger-light); color: var(--danger); }
.msg.warn { background: var(--warning-light); color: #b45309; }
.toast-fixed {
  position: fixed;
  top: 18px;
  right: 24px;
  z-index: 200;
  box-shadow: var(--shadow);
  animation: slideIn .25s ease;
}
@keyframes slideIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }

/* 空状态 */
.empty { text-align: center; padding: 40px 0; color: var(--gray-400); }
.empty i { font-size: 46px; margin-bottom: 12px; color: var(--gray-300); }
.empty-title { font-size: 14px; margin-bottom: 6px; color: var(--gray-500); }
.empty-sub { font-size: 12px; color: var(--gray-400); }

/* 表单布局 */
.form-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.form-row label { font-size: 13px; color: var(--gray-500); white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; margin-bottom: 12px; }
.form-grid .field label { display: block; font-size: 12px; color: var(--gray-500); margin-bottom: 5px; }
.form-grid .field input, .form-grid .field select, .form-grid .field textarea { width: 100%; }

/* 看板统计卡 */
.stat-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; margin-bottom: 18px; }
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 18px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  gap: 14px;
}
.stat-card .icon {
  width: 46px; height: 46px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; color: #fff;
}
.stat-card .icon.blue { background: var(--primary); }
.stat-card .icon.green { background: var(--success); }
.stat-card .icon.orange { background: var(--warning); }
.stat-card .icon.gray { background: var(--gray-400); }
.stat-card .num { font-size: 26px; font-weight: 700; color: var(--gray-800); line-height: 1.1; }
.stat-card .lbl { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* 快捷入口 */
.quick-links { display: flex; gap: 10px; flex-wrap: wrap; }
.quick-links a { text-decoration: none; }

/* tabs */
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--gray-200); padding-bottom: 6px; }
.tab {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-500);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { background: var(--gray-100); color: var(--gray-700); }
.tab.active { background: var(--primary-light); color: var(--primary); font-weight: 600; }

/* 候诊叫号 */
.queue-board { display: flex; gap: 16px; flex-wrap: wrap; }
.queue-col { flex: 1; min-width: 240px; background: var(--gray-50); border-radius: var(--radius); padding: 14px; border: 1px solid var(--gray-100); }
.queue-col h4 { font-size: 14px; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 2px solid var(--gray-200); color: var(--gray-600); }
.queue-item {
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid transparent;
}
.queue-item .no { font-weight: 700; color: var(--primary); margin-right: 6px; }
.queue-item.doing { border-left-color: var(--success); }
.queue-item.skipped { border-left-color: var(--danger); opacity: .8; }
.call-display { text-align: center; padding: 32px; background: linear-gradient(135deg, #1e3a8a, #2563eb); color: #fff; border-radius: var(--radius); margin-bottom: 18px; box-shadow: var(--shadow); }
.call-display .name { font-size: 38px; font-weight: 700; margin: 10px 0; }
.call-display .no { font-size: 22px; color: #fde047; }

/* 条形图 */
.bar-chart { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding: 10px 4px 0; border-bottom: 2px solid var(--gray-200); }
.bar-chart .bar-wrap { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; min-width: 0; }
.bar-chart .bar { width: 70%; background: var(--primary); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar-chart .bar.green { background: var(--success); }
.bar-labels { display: flex; gap: 6px; padding: 6px 4px; }
.bar-labels span { flex: 1; text-align: center; font-size: 11px; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* 时间线 */
.timeline { border-left: 2px solid var(--gray-200); margin-left: 8px; padding-left: 18px; }
.timeline .t-item { position: relative; margin-bottom: 16px; }
.timeline .t-item::before {
  content: '';
  position: absolute;
  left: -24px; top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--gray-200);
}
.timeline .t-time { font-size: 12px; color: var(--gray-400); }
.timeline .t-title { font-size: 13px; margin-top: 2px; color: var(--gray-700); }

/* 用药安全审核 */
.rx-alert { font-size: 12px; padding: 8px 10px; border-radius: var(--radius-sm); margin-top: 6px; line-height: 1.5; }
.rx-alert.sev-high { background: var(--danger-light); color: #991b1b; border-left: 3px solid var(--danger); }
.rx-alert.sev-medium { background: var(--warning-light); color: #92400e; border-left: 3px solid var(--warning); }
.rx-alert.sev-low { background: var(--primary-light); color: #1e40af; border-left: 3px solid var(--primary); }
.rx-sev { font-weight: 700; margin-right: 4px; }

/* 智能预警条 */
.alert-bar {
  background: var(--danger);
  color: #fff;
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
}
.alert-bar:hover { background: #b91c1c; }

/* 扫码/库存 */
.scan-input { min-width: 320px; font-size: 15px; padding: 10px 12px; }
.qi-row { flex-wrap: wrap; }
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px 22px;
  max-width: 760px;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  box-shadow: var(--shadow-lg);
}
.modal-box h3 { margin-bottom: 14px; color: var(--gray-800); }

/* 扫码盘点 */
.stocktake-page .st-scan-input { flex: 1; min-width: 220px; font-size: 17px; padding: 12px 14px; }
.st-scan-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.st-stepper { display: flex; align-items: center; gap: 4px; }
.st-stepper .st-qty { width: 64px; text-align: center; font-size: 16px; font-weight: 700; }
.st-video { width: 100%; max-width: 420px; border-radius: var(--radius); background: #000; margin-top: 8px; }
.st-last { font-size: 13px; color: var(--gray-600); margin-top: 8px; }
.st-board { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.st-stat {
  flex: 1; min-width: 110px;
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  border: 1px solid var(--gray-100);
}
.st-stat .num { font-size: 26px; font-weight: 700; color: var(--primary); }
.st-stat .lbl { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.st-stat.profit .num { color: var(--success); }
.st-stat.loss .num { color: var(--danger); }

/* 打印 */
.print-root { display: none; }
@media print {
  body * { visibility: hidden; }
  .print-root, .print-root * { visibility: visible; }
  .print-root { display: block !important; position: absolute; left: 0; top: 0; width: 100%; }
  #app { display: none !important; }
  @page { size: A4; margin: 18mm 16mm; }
}

/* 医疗文书 */
.doc-head { text-align: center; border-bottom: 2px solid #333; padding-bottom: 8px; margin-bottom: 12px; }
.doc-clinic { font-size: 22px; font-weight: 700; letter-spacing: 4px; }
.doc-title { font-size: 18px; font-weight: 700; margin: 6px 0 2px; letter-spacing: 8px; }
.doc-sub { font-size: 12px; color: #555; }
.doc-meta { display: flex; gap: 24px; font-size: 13px; margin-bottom: 8px; flex-wrap: wrap; }
.doc-sec { font-weight: 700; font-size: 15px; margin: 8px 0 4px; }
.doc-table { width: 100%; border-collapse: collapse; font-size: 12px; margin: 6px 0; }
.doc-table th, .doc-table td { border: 1px solid #444; padding: 5px 7px; text-align: left; }
.doc-table th { background: #f0f0f0; }
.doc-total { text-align: right; font-size: 13px; font-weight: 700; margin: 8px 0; }
.doc-sign { display: flex; justify-content: space-between; gap: 20px; font-size: 13px; margin-top: 28px; }
.doc-line { font-size: 14px; margin: 12px 0; line-height: 1.9; }
.doc-note { font-size: 11px; color: #666; margin-top: 24px; border-top: 1px dashed #999; padding-top: 8px; }
@media print {
  .doc-head { border-bottom: 1.5px solid #000; }
  .doc-table th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* 移动端 */
@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; overflow-x: auto; align-items: center; }
  .sidebar .logo { padding: 12px 14px; font-size: 14px; white-space: nowrap; border-bottom: none; border-right: 1px solid rgba(255,255,255,.08); }
  .sidebar .logo small { display: none; }
  .sidebar a.menu { padding: 12px 14px; white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .sidebar a.menu.active { border-left: none; border-bottom-color: var(--primary); }
  .login-wrap { flex-direction: column; }
  .login-brand { padding: 30px; }
  .login-brand h1 { font-size: 28px; }
  .login-form-panel { width: 100%; min-width: 0; padding: 20px; }
  .content { padding: 14px; }
  .card { padding: 14px; }
  .btn { padding: 10px 16px; font-size: 15px; }
  .btn.sm { padding: 6px 10px; font-size: 13px; }
  input, select, textarea { font-size: 15px; padding: 10px 12px; }
  .scan-input { min-width: 0; width: 100%; }
  .st-scan-row { flex-direction: column; align-items: stretch; }
  .st-stepper { justify-content: center; }
  .st-stepper .st-qty { width: 80px; font-size: 18px; }
  .st-stepper .btn { padding: 10px 18px; font-size: 18px; }
  table.grid { font-size: 14px; }
  .stocktake-page .st-scan-input { font-size: 18px; }
  .st-board { gap: 8px; }
  .st-stat { min-width: 44%; padding: 10px 6px; }
  .st-stat .num { font-size: 22px; }
}
