/* 宠物医院管理系统 - 基础设计系统（零外部依赖） */
:root {
  --bg: #f2f5f9;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --text: #16202f;
  --text-2: #4a5568;
  --muted: #8493a8;
  --border: #e4e9f0;
  --border-2: #eef2f7;
  --primary: #0d9488;
  --primary-2: #0f766e;
  --primary-soft: #e6fffb;
  --blue: #2563eb;
  --blue-soft: #eff6ff;
  --violet: #7c3aed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --sidebar: #101a2b;
  --sidebar-2: #0b1322;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 32, 54, .06), 0 4px 16px rgba(16, 32, 54, .05);
  --shadow-lg: 0 12px 40px rgba(16, 32, 54, .18);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd8e3; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ---------------- 布局 ---------------- */
#app-shell { display: flex; min-height: 100vh; }

#sidebar {
  width: 226px;
  flex: 0 0 226px;
  background: linear-gradient(180deg, var(--sidebar) 0%, var(--sidebar-2) 100%);
  color: #c9d4e4;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .07);
}
.brand-logo {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), #22c1a5);
  display: flex; align-items: center; justify-content: center;
  color: #fff; flex: 0 0 36px;
}
.brand-logo svg { width: 21px; height: 21px; }
.brand-name { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .3px; }
.brand-sub { font-size: 11px; color: #7d8ba3; margin-top: 1px; }

.nav-group { padding: 3px 10px; }
.nav-group-title {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  min-height: 42px; border: 0; border-radius: 8px; background: transparent;
  font: inherit; font-size: 12px; color: #9aabc2; padding: 10px 11px;
  text-align: left; letter-spacing: .6px; font-weight: 600; cursor: pointer;
}
.nav-group-title:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.current-group > .nav-group-title { color: #64dfce; }
.nav-chevron { width: 14px; height: 14px; flex-shrink: 0; transition: transform .15s; }
.nav-group-title[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }
.nav-group-items { padding: 3px 0 5px; }
.nav-group-items[hidden] { display: none !important; }
.nav-tools { display: flex; align-items: center; justify-content: space-between; padding: 15px 21px 8px; color: #71839d; font-size: 10px; }
.nav-tools button { border: 0; background: transparent; color: #9aabc2; font: inherit; font-size: 11px; padding: 5px 0 5px 8px; cursor: pointer; }
.nav-tools button:hover { color: #fff; }
@media (prefers-reduced-motion: reduce) { .nav-chevron { transition: none; } }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 11px; margin: 1px 0; border-radius: 9px;
  cursor: pointer; color: #b9c6d8; font-size: 13.5px;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.nav-item:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.nav-item.active {
  background: linear-gradient(90deg, rgba(13, 148, 136, .95), rgba(13, 148, 136, .55));
  color: #fff; font-weight: 600;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08);
}
.nav-item .icon { width: 18px; height: 18px; flex: 0 0 18px; }
.nav-badge {
  margin-left: auto; background: var(--danger); color: #fff;
  font-size: 10.5px; padding: 1px 6px; border-radius: 9px; font-weight: 600;
}

main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  height: 60px; background: var(--panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px; padding: 0 22px;
  position: sticky; top: 0; z-index: 30;
}
#topbar h1 { font-size: 17px; margin: 0; font-weight: 650; }
#topbar .crumb { color: var(--muted); font-size: 12.5px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who {
  display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2);
  background: var(--panel-2); padding: 5px 12px; border-radius: 20px; border: 1px solid var(--border);
}
.avatar {
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600;
}
#view { padding: 20px 22px 40px; flex: 1; }

/* ---------------- 通用组件 ---------------- */
.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 10px;
}
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; }
.card-head .sub { font-size: 12px; color: var(--muted); }
.card-head .right { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.card-body { padding: 16px 18px; }
.card-body.flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1180px) { .g4 { grid-template-columns: repeat(2, 1fr); } .g3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 860px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

/* KPI */
.kpi {
  background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.kpi .k-label { font-size: 12.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.kpi .k-value { font-size: 26px; font-weight: 700; margin-top: 6px; letter-spacing: -.5px; }
.kpi .k-unit { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi .k-foot { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
.kpi::after {
  content: ""; position: absolute; right: -18px; top: -18px;
  width: 74px; height: 74px; border-radius: 50%; background: var(--primary-soft); opacity: .55;
}
.kpi.blue::after { background: var(--blue-soft); }
.kpi.warn::after { background: var(--warn-soft); }
.kpi.violet::after { background: #f5f3ff; }
.kpi.danger::after { background: var(--danger-soft); }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--panel);
  color: var(--text-2); padding: 7px 13px; border-radius: var(--radius-sm);
  font-size: 13px; cursor: pointer; font-family: inherit;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: var(--panel-2); color: var(--text); }
.btn .icon { width: 15px; height: 15px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-2); border-color: var(--primary-2); color: #fff; }
.btn-blue { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-blue:hover { background: #1d4ed8; border-color: #1d4ed8; color: #fff; }
.btn-danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-sm { padding: 4px 9px; font-size: 12px; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--panel-2); border-color: var(--border); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* 表单 */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 13px; }
.field > label { font-size: 12.5px; color: var(--text-2); font-weight: 550; }
.field .hint { font-size: 11.5px; color: var(--muted); }
input, select, textarea {
  font-family: inherit; font-size: 13.5px; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 8px 11px; background: #fff; width: 100%; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13, 148, 136, .13);
}
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
.toolbar {
  display: flex; gap: 9px; align-items: center; flex-wrap: wrap;
  padding: 12px 18px; border-bottom: 1px solid var(--border-2);
}
.toolbar input, .toolbar select { width: auto; min-width: 130px; }
.toolbar .grow { flex: 1; }

/* 表格 */
.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.2px; }
table.tbl th {
  text-align: left; font-weight: 600; color: var(--muted); font-size: 12px;
  padding: 10px 14px; background: var(--panel-2); border-bottom: 1px solid var(--border);
  white-space: nowrap; letter-spacing: .2px;
}
table.tbl td {
  padding: 11px 14px; border-bottom: 1px solid var(--border-2); vertical-align: middle;
}
table.tbl tbody tr:hover { background: #f9fbfd; }
table.tbl tbody tr.clickable { cursor: pointer; }
table.tbl .num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.strong { font-weight: 600; }

/* 标签 */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 20px; font-size: 11.5px; font-weight: 600;
  background: var(--panel-2); color: var(--text-2); border: 1px solid var(--border);
  white-space: nowrap;
}
.badge.ok, .badge.green { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.badge.warn, .badge.orange { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge.danger, .badge.red { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge.info, .badge.blue { background: var(--blue-soft); color: var(--blue); border-color: #bfdbfe; }
.badge.primary, .badge.teal { background: var(--primary-soft); color: var(--primary-2); border-color: #99f6e4; }
.badge.violet { background: #f5f3ff; color: var(--violet); border-color: #ddd6fe; }
.badge.gray { background: #f1f5f9; color: #64748b; }

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.danger { background: var(--danger); }
.dot.off { background: #cbd5e1; }

/* 图表 */
.bars { display: flex; align-items: flex-end; gap: 8px; height: 150px; padding-top: 8px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; min-width: 0; }
.bar {
  width: 100%; max-width: 34px; background: linear-gradient(180deg, #2dd4bf, var(--primary));
  border-radius: 5px 5px 0 0; min-height: 0;
}
.bar.blue { background: linear-gradient(180deg, #60a5fa, var(--blue)); }
.bar-label { font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.bar-value { font-size: 10.5px; color: var(--text-2); font-weight: 600; }

.hbar { margin-bottom: 11px; }
.hbar-top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 4px; }
.hbar-track { height: 8px; background: var(--panel-2); border-radius: 6px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; background: var(--primary); }
.hbar-fill.blue { background: var(--blue); }
.hbar-fill.violet { background: var(--violet); }
.hbar-fill.warn { background: var(--warn); }

.donut-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.legend { display: flex; flex-direction: column; gap: 7px; flex: 1; min-width: 150px; }
.legend-item { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.legend-item .swatch { width: 10px; height: 10px; border-radius: 3px; }
.legend-item .val { margin-left: auto; font-weight: 600; }

/* 模态框 */
#modal-root .mask {
  position: fixed; inset: 0; background: rgba(11, 19, 34, .5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  padding: 24px; backdrop-filter: blur(2px);
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0; } }
.modal {
  background: var(--panel); border-radius: 14px; box-shadow: var(--shadow-lg);
  width: 100%; max-width: 560px; max-height: 88vh; display: flex; flex-direction: column;
  animation: pop .18s cubic-bezier(.2, .9, .3, 1.2);
}
.modal.wide { max-width: 860px; }
.modal.xwide { max-width: 1080px; }
@keyframes pop { from { transform: translateY(12px) scale(.98); opacity: 0; } }
.modal-head {
  padding: 16px 20px; border-bottom: 1px solid var(--border-2);
  display: flex; align-items: center; gap: 10px;
}
.modal-head h3 { margin: 0; font-size: 15.5px; font-weight: 650; }
.modal-head .x {
  margin-left: auto; cursor: pointer; color: var(--muted); font-size: 20px;
  line-height: 1; padding: 2px 6px; border-radius: 6px;
}
.modal-head .x:hover { background: var(--panel-2); color: var(--text); }
.modal-body { padding: 18px 20px; overflow-y: auto; flex: 1; }
.modal-foot {
  padding: 13px 20px; border-top: 1px solid var(--border-2);
  display: flex; justify-content: flex-end; gap: 9px;
}

/* Toast */
#toast-root {
  position: fixed; top: 18px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 9px; align-items: center;
}
.toast {
  background: #16202f; color: #fff; padding: 9px 18px; border-radius: 22px;
  font-size: 13px; box-shadow: var(--shadow-lg); animation: drop .2s ease;
  display: flex; align-items: center; gap: 7px; max-width: 80vw;
}
.toast.ok { background: #15803d; }
.toast.err { background: #b91c1c; }
.toast.warn { background: #b45309; }
@keyframes drop { from { transform: translateY(-12px); opacity: 0; } }

/* 详情 / 描述列表 */
.desc { display: grid; grid-template-columns: 96px 1fr; gap: 8px 12px; font-size: 13px; }
.desc dt { color: var(--muted); }
.desc dd { margin: 0; }
.kv-list { display: flex; flex-direction: column; gap: 9px; }
.kv { display: flex; gap: 10px; font-size: 13px; align-items: baseline; }
.kv .k { color: var(--muted); flex: 0 0 88px; font-size: 12.5px; }
.kv .v { flex: 1; }

.timeline { position: relative; padding-left: 20px; }
.timeline::before {
  content: ""; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; margin-bottom: 15px; }
.tl-item::before {
  content: ""; position: absolute; left: -19px; top: 5px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #fff; border: 2px solid var(--primary);
}
.tl-item .tl-time { font-size: 11.5px; color: var(--muted); }
.tl-item .tl-title { font-size: 13px; font-weight: 600; }
.tl-item .tl-body { font-size: 12.5px; color: var(--text-2); margin-top: 3px; }

.empty {
  padding: 46px 20px; text-align: center; color: var(--muted); font-size: 13px;
}
.empty .icon { width: 34px; height: 34px; opacity: .35; display: block; margin: 0 auto 8px; }

.skeleton { padding: 30px; text-align: center; color: var(--muted); font-size: 13px; }

/* 分页 */
.pager {
  display: flex; align-items: center; gap: 10px; padding: 12px 18px;
  border-top: 1px solid var(--border-2); font-size: 12.5px; color: var(--muted);
}
.pager .grow { flex: 1; }

/* 标签页 */
.tabs { display: flex; gap: 3px; border-bottom: 1px solid var(--border); margin-bottom: 0; }
.tab {
  padding: 9px 15px; cursor: pointer; font-size: 13.5px; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }

/* 影像相关 */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 13px; }
.img-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
  background: #000; cursor: pointer; position: relative;
}
.img-card img { width: 100%; height: 148px; object-fit: cover; display: block; }
.img-meta {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 6px 9px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, .8));
  color: #fff; font-size: 11.5px;
}
.viewer { background: #000; border-radius: 8px; overflow: hidden; text-align: center; }
.viewer img { max-width: 100%; max-height: 62vh; object-fit: contain; }

/* 检验结果 */
.res-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 10px; }
.res-item {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 12px;
  display: flex; justify-content: space-between; align-items: center; background: #fff;
}
.res-item.abn { border-color: #fecaca; background: var(--danger-soft); }
.res-item.crit { border-color: var(--danger); background: #fee2e2; }
.res-item .rn { font-size: 12.5px; color: var(--text-2); }
.res-item .rv { font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.res-item .ru { font-size: 11.5px; color: var(--muted); }

/* 聊天 */
.chat-wrap { display: flex; flex-direction: column; height: 460px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 14px; background: var(--panel-2); }
.msg { display: flex; margin-bottom: 12px; gap: 9px; }
.msg.me { flex-direction: row-reverse; }
.msg .bubble {
  max-width: 72%; padding: 9px 13px; border-radius: 12px; font-size: 13.2px;
  background: #fff; border: 1px solid var(--border); line-height: 1.55;
}
.msg.me .bubble { background: var(--primary); color: #fff; border-color: var(--primary); }
.msg .who { font-size: 11px; color: var(--muted); margin-bottom: 3px; }
.msg.me .who { text-align: right; }
.chat-input { display: flex; gap: 9px; padding: 12px; border-top: 1px solid var(--border); }
.chat-input textarea { min-height: 44px; }

/* 快捷入口 */
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 11px; }
.quick {
  border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 13px;
  cursor: pointer; text-align: center; transition: all .15s; background: #fff;
}
.quick:hover { border-color: var(--primary); background: var(--primary-soft); transform: translateY(-1px); }
.quick .icon { width: 22px; height: 22px; color: var(--primary); }
.quick .qt { font-size: 13px; font-weight: 600; margin-top: 6px; }
.quick .qs { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

.list-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--border-2); font-size: 13px;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: #f9fbfd; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .lt { font-weight: 550; }
.list-item .ls { font-size: 11.5px; color: var(--muted); }

.section-title {
  font-size: 13px; font-weight: 650; color: var(--muted); letter-spacing: .3px;
  margin: 4px 0 10px; display: flex; align-items: center; gap: 7px;
}
.section-title .icon { width: 15px; height: 15px; }

pre.raw {
  background: #0f172a; color: #a5d6d0; padding: 11px 13px; border-radius: 8px;
  font-size: 11.5px; overflow-x: auto; line-height: 1.5; margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.link { cursor: pointer; color: var(--primary); }
.link:hover { text-decoration: underline; }

/* 自适应布局：内容随视口重排，只有明细表和趋势图允许局部横向滚动。 */
.nav-item { width: 100%; border: 0; background: transparent; text-align: left; font-family: inherit; }
.menu-toggle, .nav-close, .nav-backdrop { display: none; }
.grid > *, .form-row > *, .form-row-3 > *, .card, .card-body,
.cell-value, .field, .kv .v, .desc dd { min-width: 0; }
.grid > .card + .card { margin-top: 0; }
.form-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card-head, .card-head .right, .modal-head, .modal-foot, .pager { flex-wrap: wrap; }
.card-head h3, .modal-head h3 { min-width: 0; overflow-wrap: anywhere; }
.card-head .right { max-width: 100%; }
.table-wrap, .tabs, .bars { max-width: 100%; overscroll-behavior-x: contain; }
.table-wrap { -webkit-overflow-scrolling: touch; }
.tabs { overflow-x: auto; }
.tab { flex-shrink: 0; }
.bars { overflow-x: auto; height: 170px; padding-bottom: 8px; }
.bar-item { min-width: 32px; }
.cell-value, .desc dd, .kv .v, .list-item .grow, .msg .bubble { overflow-wrap: anywhere; }
.modal { min-width: 0; max-height: calc(100dvh - 48px); }
.modal-head, .modal-foot { flex-shrink: 0; }
.modal-body { min-height: 0; }
.modal-head .x { flex-shrink: 0; }
.modal-head .x svg { width: 22px; height: 22px; }
.table-wrap:not(:has(.responsive-table)) table { min-width: 600px; }
body.modal-open { overflow: hidden; }
.toolbar > input, .toolbar > select { min-width: 0; max-width: 100%; }
.chat-msgs { min-height: 0; }
.msg > div { min-width: 0; max-width: 100%; }
.msg .bubble { max-width: 100%; }
.consult-layout { display: flex; min-height: 520px; }
.consult-list { width: 330px; flex: 0 0 330px; border-right: 1px solid var(--border); overflow-y: auto; max-height: 560px; }
.consult-chat { flex: 1; min-width: 0; }
.consult-heading { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.dashboard-trend { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.dashboard-todo { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.study-layout { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
.vitals-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
button:focus-visible, a:focus-visible { outline: 3px solid var(--primary); outline-offset: 3px; }

@media (max-width: 1200px) {
  .dashboard-trend, .dashboard-todo { grid-template-columns: minmax(0, 1fr); }
  #topbar { gap: 10px; padding-inline: 16px; }
  #topbar .crumb { display: none; }
  .consult-list { width: 280px; flex-basis: 280px; }
}

@media (max-width: 960px) {
  #sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(300px, 88vw); height: 100dvh;
    z-index: 90; transform: translateX(-100%); visibility: hidden;
    padding-bottom: env(safe-area-inset-bottom);
    transition: transform .2s ease, visibility .2s;
  }
  #sidebar .brand { padding: 16px 12px; gap: 8px; }
  #sidebar .brand-name { font-size: 14px; }
  .nav-close { display: inline-flex; margin-left: auto; padding: 8px; color: #fff; border-color: #475569; background: transparent; }
  .nav-item { min-height: 44px; }
  .menu-toggle { display: inline-flex; justify-content: center; min-width: 40px; min-height: 40px; padding: 5px 10px; font-size: 21px; }
  .nav-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 80; border: 0; background: rgba(11, 19, 34, .5); }
  body.nav-open { overflow: hidden; }
  .nav-open #sidebar { transform: translateX(0); visibility: visible; }
  main { width: 100%; }
  #view { padding: 16px 16px 32px; }
  .study-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 640px) {
  #topbar { height: auto; min-height: 60px; gap: 8px; padding: 8px max(12px, env(safe-area-inset-right)) 8px max(12px, env(safe-area-inset-left)); }
  #topbar h1 { font-size: 16px; }
  .topbar-right { gap: 0; }
  .topbar-right .who { display: none; }
  .topbar-right .btn { min-height: 40px; padding: 7px 9px; }
  #view { padding: 12px 12px calc(24px + env(safe-area-inset-bottom)); }
  .grid { gap: 12px; }
  .g2, .g3, .dashboard-trend, .dashboard-todo { grid-template-columns: minmax(0, 1fr); }
  .g4, .vitals-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi { padding: 12px; }
  .kpi .k-value { font-size: clamp(20px, 5.5vw, 26px); overflow-wrap: anywhere; }
  .kpi .k-label, .kpi .k-foot { font-size: 11px; }
  .card-head, .card-body { padding: 12px; }
  .card-head .sub { font-size: 11px; }
  .card-head .right { gap: 6px; }
  .toolbar { padding: 12px; gap: 8px; }
  .toolbar > input, .toolbar > select { flex: 1 1 130px; width: 100% !important; }
  .toolbar .grow { display: none; }
  .btn { min-height: 40px; justify-content: center; }
  .btn-sm { padding: 7px 10px; }
  input, select, textarea { min-width: 0; max-width: 100%; font-size: 16px; }
  input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; }
  .form-row, .form-row-3 { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .form-row > .field, .form-row-3 > .field { grid-column: 1 / -1 !important; }
  .pager { gap: 8px; padding: 12px; }
  .pager > span:first-child { width: 100%; }
  .pager .grow { display: none; }
  .tabs { padding-inline: 4px; }
  .tab { padding: 12px; }
  .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .img-grid { grid-template-columns: repeat(auto-fill, minmax(min(140px, 100%), 1fr)); }
  .res-grid { grid-template-columns: minmax(0, 1fr); }
  .list-item { flex-wrap: wrap; padding: 10px 12px; gap: 8px; }
  .list-item .grow { flex-basis: 50%; }
  .desc { grid-template-columns: 72px minmax(0, 1fr); gap: 8px; }
  .kv .k { flex-basis: 72px; }
  #modal-root .mask { padding: 10px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
  .modal { max-height: calc(100dvh - 20px - env(safe-area-inset-bottom)); border-radius: 12px; }
  .modal-head, .modal-foot { padding: 12px; gap: 8px; }
  .modal-head { flex-wrap: nowrap; }
  .modal-body { padding: 12px; }
  .modal-foot .btn { flex: 1 1 auto; white-space: normal; }
  .consult-layout { flex-direction: column; min-height: 0; }
  .consult-list { width: 100%; flex: auto; max-height: 240px; border-right: 0; border-bottom: 1px solid var(--border); }
  .consult-heading { padding: 12px; }
  .chat-wrap { height: min(520px, 70dvh); min-height: 280px; }
  .chat-input textarea { flex: 1; width: 0; }

  /* 每行显示完整字段及原有操作，避免将整张桌面表格缩小到手机里。 */
  table.responsive-table, .responsive-table tbody { display: block; width: 100%; }
  .responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .responsive-table tbody tr { display: block; margin: 10px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 10px; background: #fff; }
  table.responsive-table td { display: grid; grid-template-columns: 80px minmax(0, 1fr); gap: 10px; padding: 8px 0; text-align: left; }
  .responsive-table td::before { content: attr(data-label); color: var(--muted); font-size: 12px; }
  table.responsive-table td[data-label=""] { display: block; }
  .responsive-table td[data-label=""]::before { display: none; }
  .responsive-table td:last-child { border-bottom: 0; }
  .responsive-table .cell-value { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; }
}

@media (prefers-reduced-motion: reduce) {
  #sidebar { transition: none; }
}

.pet-chip {
  display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px;
  background: var(--panel-2); border: 1px solid var(--border);
  padding: 2px 9px; border-radius: 20px;
}

/* 可操作的工作台与跨窗口更新提示。 */
.workbench-kpi { width: 100%; text-align: left; font: inherit; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.quick { font: inherit; color: var(--text); background: var(--panel); }
.workbench-kpi:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.workbench-row, .consult-session { width: 100%; text-align: left; color: var(--text); font: inherit; background: var(--panel); border: 0; border-bottom: 1px solid var(--border-2); cursor: pointer; }
.workbench-row:hover, .consult-session:hover { background: var(--panel-2); }
.workbench-row:focus-visible, .workbench-kpi:focus-visible, .consult-session:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.consult-session.selected { background: var(--primary-soft); box-shadow: inset 3px 0 var(--primary); }
.consult-session .lt, .consult-session .ls { display: block; }
.consult-session > span:last-child { flex-shrink: 0; }
.consult-closed { padding: 15px; text-align: center; color: var(--muted); background: var(--panel-2); border-top: 1px solid var(--border); font-size: 12px; }
.modal-head .x { display: inline-flex; align-items: center; justify-content: center; background: transparent; border: 0; min-width: 32px; min-height: 32px; }
.topbar-refresh { flex-shrink: 0; }
#data-update-notice { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 24px 0; padding: 10px 14px; border: 1px solid #b9d9ec; border-radius: 9px; background: #edf7fd; color: #245e7e; font-size: 12px; }
#data-update-notice[hidden] { display: none; }
#data-update-notice > span { display: flex; align-items: center; gap: 8px; }
#data-update-notice .icon { flex-shrink: 0; width: 16px; height: 16px; }
.signed-bars { align-items: stretch; }
.signed-bars .bar-item { justify-content: flex-end; }
.signed-plot { position: relative; width: 100%; height: 118px; flex: 0 0 118px; }
.signed-zero { position: absolute; width: calc(100% + 8px); left: -4px; border-top: 1px dashed #9cacb9; }
.signed-bar { position: absolute; width: 100%; max-width: 34px; left: 50%; transform: translateX(-50%); border-radius: 3px; background: var(--primary); }
.signed-bar.negative, .hbar-fill.negative { background: var(--danger); }
.negative-value { color: var(--danger); }
.billing-claim-link { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 12px 14px; margin-bottom: 14px; border-radius: 9px; border: 1px solid #cdebe5; background: #f2fbf8; }
.billing-claim-link strong { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; color: var(--primary-2); }
.billing-claim-link .icon { width: 16px; height: 16px; }
@media (max-width: 640px) { #data-update-notice { margin: 10px 12px 0; align-items: flex-start; } #data-update-notice .btn { flex-shrink: 0; } }

/* Unified clinical and administration workbench. */
.view-content { min-width: 0; }
.workbench-welcome { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 26px 28px; margin-bottom: 20px; border: 1px solid #cce8e3; border-radius: 14px; background: linear-gradient(110deg, #e6f6f1 0%, #f1faf8 56%, #eaf3fd 100%); }
.welcome-eyebrow { color: #28796d; font-size: 10px; letter-spacing: 1.5px; font-weight: 700; }
.workbench-welcome h2 { margin: 6px 0 8px; font-size: clamp(19px, 2vw, 25px); letter-spacing: -.6px; }
.workbench-welcome p { margin: 0; color: #58706d; font-size: 12px; }
.welcome-actions { display: flex; flex-wrap: wrap; gap: 8px; flex-shrink: 0; max-width: 100%; min-width: 0; }
.workbench-oa { margin: 0 0 20px; }
.workbench-oa .card-head h3 { display: flex; align-items: center; gap: 8px; }
.workbench-oa .card-head h3 .icon { width: 18px; height: 18px; flex: 0 0 18px; }
.workbench-oa-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.workbench-metric { display: flex; align-items: center; gap: 14px; text-align: left; padding: 18px 22px; border: 0; border-right: 1px solid var(--border-2); background: white; color: var(--text); font: inherit; cursor: pointer; }
.workbench-metric:last-child { border-right: 0; }
.workbench-metric:hover { background: var(--panel-2); }
.workbench-metric > span:last-child { display: flex; flex-direction: column; }
.workbench-metric strong { font-size: 25px; line-height: 1.35; }
.workbench-metric-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; color: var(--primary); background: #eef8f5; flex-shrink: 0; }
.workbench-metric-icon .icon { width: 23px; height: 23px; }
.quick-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.workbench-metric:nth-child(2) .workbench-metric-icon { background: var(--blue-soft); color: var(--blue); }
.workbench-metric:nth-child(3) .workbench-metric-icon { background: var(--warn-soft); color: var(--warn); }
.workbench-metric:nth-child(4) .workbench-metric-icon { background: #f4efff; color: var(--violet); }
@media (max-width: 1200px) { .workbench-welcome { align-items: flex-start; flex-direction: column; gap: 14px; } .workbench-metric { padding: 15px; gap: 10px; } }
@media (max-width: 640px) { .workbench-welcome { padding: 18px; } .workbench-oa-grid, .quick-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .workbench-metric { padding: 13px; border-bottom: 1px solid var(--border-2); } .workbench-metric-icon { width: 30px; height: 30px; border-radius: 8px; } .workbench-metric .small { font-size: 10px; } .workbench-oa .card-head .sub { display: none; } }
