:root {
  --bg: #eef2f7;
  --bg-soft: #f7f9fc;
  --card: #ffffff;
  --ink: #16232f;
  --ink-2: #4a5a6a;
  --ink-3: #8494a4;
  --line: #e3eaf2;
  --brand: #0b5cab;
  --brand-2: #1478d4;
  --brand-soft: #e8f1fb;
  --teal: #0d9488;
  --teal-soft: #e6f6f4;
  --amber: #b45309;
  --amber-soft: #fdf1e0;
  --red: #c0392b;
  --red-soft: #fdecea;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(16, 42, 67, .08);
  --shadow-lg: 0 18px 48px rgba(11, 42, 74, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1100px 500px at 85% -10%, #dfeafa 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; display: flex; flex-direction: column; }

button, input, textarea, select { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
a { color: var(--brand); text-decoration: none; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 26px;
  background: rgba(255, 255, 255, .86);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }

.logo {
  width: 42px; height: 42px;
  flex: 0 0 42px;
  border-radius: 12px;
  background: linear-gradient(140deg, #0b5cab, #1478d4 60%, #38a3e0);
  color: #fff;
  font-weight: 700;
  font-size: 19px;
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(11, 92, 171, .28);
}

.brand-text h1 { margin: 0; font-size: 18px; letter-spacing: .3px; }
.brand-text p { margin: 2px 0 0; font-size: 12px; color: var(--ink-3); }

.top-actions { display: flex; align-items: center; gap: 12px; flex: 1; justify-content: flex-end; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  height: 40px;
  width: 360px;
  max-width: 46vw;
  transition: .18s;
}
.search:focus-within { border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 3px rgba(20, 120, 212, .12); }
.search svg { width: 17px; height: 17px; stroke: var(--ink-3); stroke-width: 2; fill: none; flex: 0 0 17px; }
.search input { border: 0; background: transparent; outline: none; width: 100%; font-size: 13.5px; }
.search input::placeholder { color: #a4b1c0; }
.search-clear { border: 0; background: transparent; color: var(--ink-3); font-size: 18px; line-height: 1; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 40px;
  padding: 0 18px;
  border-radius: 10px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .12s, box-shadow .18s, background .18s;
}
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(135deg, #0b5cab, #1478d4); color: #fff; box-shadow: 0 8px 18px rgba(11, 92, 171, .22); }
.btn.primary:hover { box-shadow: 0 10px 24px rgba(11, 92, 171, .3); }
.btn.outline { border-color: var(--brand-2); color: var(--brand); background: #fff; }
.btn.outline:hover { background: var(--brand-soft); }
.btn.ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg-soft); }
.btn.danger.ghost { color: var(--red); border-color: #f3d0cc; background: #fff; }
.btn.danger.ghost:hover { background: var(--red-soft); }
.btn.sm { height: 34px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn .plus { font-size: 17px; line-height: 1; }
.btn svg.ico { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.8; }

/* ---------- 主区 ---------- */
main { width: min(1330px, 100%); margin: 0 auto; padding: 22px 26px 10px; flex: 1; }

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 18px;
}
.stat {
  display: flex; align-items: center; gap: 13px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 18px;
  box-shadow: 0 2px 10px rgba(16, 42, 67, .04);
}
.stat-icon {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 11px;
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.stat-icon.blue { background: var(--brand-soft); color: var(--brand); }
.stat-icon.teal { background: var(--teal-soft); color: var(--teal); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-icon.gray { background: #eef1f5; color: #5b6b7c; }
.stat b { display: block; font-size: 23px; line-height: 1.15; letter-spacing: .5px; }
.stat span { font-size: 12px; color: var(--ink-3); }

.list-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  gap: 12px; flex-wrap: wrap;
}
.panel-title { display: flex; align-items: center; gap: 10px; }
.panel-title h2 { margin: 0; font-size: 16px; }
.count-chip {
  font-size: 12px; color: var(--brand);
  background: var(--brand-soft);
  padding: 3px 9px; border-radius: 999px;
}
.panel-tools { display: flex; align-items: center; gap: 14px; }
.switch { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.switch input { width: 15px; height: 15px; accent-color: var(--brand-2); }

.table-head, .patient-row {
  display: grid;
  grid-template-columns: 106px 64px 88px 116px minmax(122px, .9fr) 92px 116px minmax(118px, 1fr) minmax(96px, .62fr) 84px 72px 74px;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
}
.table-head {
  height: 40px;
  font-size: 12px;
  color: var(--ink-3);
  background: var(--bg-soft);
  border-bottom: 1px solid var(--line);
  letter-spacing: .3px;
}
.table-head .center, .patient-row .center { text-align: center; }
.table-wrap { overflow-x: auto; }
.table-head, .patient-list { min-width: 1270px; }

/* 可排序表头 */
.sortable { display: inline-flex; align-items: center; gap: 4px; cursor: pointer; user-select: none; }
.sortable:hover { color: var(--brand); }
.sort-arrow {
  width: 0; height: 0; border-left: 3px solid transparent; border-right: 3px solid transparent;
  border-top: 4px solid #b6c3d2; display: inline-block;
}
.sortable.sort-asc .sort-arrow { border-top: 0; border-bottom: 4px solid var(--brand); }
.sortable.sort-desc .sort-arrow { border-top: 4px solid var(--brand); }

.patient-row {
  min-height: 62px;
  border-bottom: 1px solid #f0f4f8;
  cursor: pointer;
  transition: background .15s;
  font-size: 13.5px;
}
.patient-row:hover { background: #f8fbff; }
.patient-row:last-child { border-bottom: 0; }

.p-name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-no { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 13px; letter-spacing: .2px; }
.p-date { font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 12.5px; white-space: nowrap; }
.p-date.muted { color: var(--ink-3); }
.p-diag { font-size: 13px; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.p-diag.muted { color: var(--ink-3); }
.p-proc { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.media-chips { display: flex; align-items: center; justify-content: center; gap: 4px; flex-wrap: nowrap; }
.media-chips .chip { white-space: nowrap; }
.chip {
  display: inline-flex; align-items: center; gap: 3px;
  font-size: 12px; padding: 2px 7px; border-radius: 999px;
  background: #eef3f9; color: #55677a;
}
.chip.img { background: var(--brand-soft); color: var(--brand); }
.chip.vid { background: var(--teal-soft); color: var(--teal); }

.badge {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 600;
}
.badge.pre { background: var(--amber-soft); color: var(--amber); }
.badge.post { background: var(--brand-soft); color: var(--brand); }
.badge.out { background: #eef1f5; color: #5b6b7c; }

.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: 6px; }
.row-actions .btn { height: 30px; padding: 0 10px; font-size: 12.5px; }
.p-meta { display: none; }
.p-notes { color: var(--ink-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 筛选栏 ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 11px 20px;
  background: #fbfdff;
  border-bottom: 1px solid var(--line);
}
.filter-group { display: flex; align-items: center; gap: 8px; }
.filter-label { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.segmented { display: flex; background: #edf2f8; border-radius: 9px; padding: 3px; gap: 2px; }
.seg {
  border: 0; background: transparent; font-size: 12.5px; padding: 6px 11px;
  border-radius: 7px; color: var(--ink-2); white-space: nowrap;
}
.seg.active { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 4px rgba(16, 42, 67, .12); }
.chip-group { display: flex; gap: 6px; }
.chip-btn {
  border: 1px solid var(--line); background: #fff; font-size: 12.5px;
  padding: 6px 13px; border-radius: 999px; color: var(--ink-2); white-space: nowrap;
}
.chip-btn:hover { border-color: #bcd8f5; color: var(--brand); }
.chip-btn.active { background: var(--brand-soft); border-color: #bcd8f5; color: var(--brand); font-weight: 600; }
.date-input {
  border: 1px solid var(--line); border-radius: 9px; height: 32px;
  padding: 0 8px; font-size: 12.5px; background: #fff; color: var(--ink-2);
  outline: none;
}
.date-input:focus { border-color: var(--brand-2); }
.tilde { font-size: 12px; color: var(--ink-3); }
.filter-tail { margin-left: auto; gap: 10px; }
.filter-summary { font-size: 12px; color: var(--ink-3); white-space: nowrap; }
.sm-link { border: 0; background: transparent; color: var(--brand); font-size: 12px; padding: 0; }

.empty {
  padding: 64px 20px;
  text-align: center;
  color: var(--ink-3);
}
.empty-art { font-size: 40px; opacity: .5; margin-bottom: 6px; }
.empty h3 { margin: 6px 0; font-size: 15px; color: var(--ink-2); font-weight: 600; }
.empty p { margin: 0; font-size: 13px; }
.empty.small { padding: 40px 20px; }

.footer {
  text-align: center; padding: 18px 20px 22px;
  font-size: 12px; color: #93a2b1;
}

/* ---------- 抽屉（患者详情） ---------- */
.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-mask { position: absolute; inset: 0; background: rgba(12, 28, 44, .42); backdrop-filter: blur(2px); animation: fade .2s ease; }
.drawer-panel {
  position: absolute; top: 0; right: 0; bottom: 0;
  width: min(880px, 100%);
  background: var(--bg-soft);
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  animation: slideIn .26s cubic-bezier(.22, .7, .3, 1);
}
@keyframes slideIn { from { transform: translateX(40px); opacity: .5; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 24px;
  background: linear-gradient(120deg, #0b5cab, #1478d4);
  color: #fff;
}
.patient-id-block { display: flex; align-items: center; gap: 13px; min-width: 0; }
.avatar {
  width: 44px; height: 44px; flex: 0 0 44px; border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .35);
  display: grid; place-items: center;
  font-size: 18px; font-weight: 700;
}
.drawer-head h2 { margin: 0; font-size: 19px; }
.drawer-head p { margin: 3px 0 0; font-size: 12.5px; opacity: .88; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.drawer-head .dot { width: 3px; height: 3px; background: rgba(255,255,255,.7); border-radius: 50%; }
.drawer-actions { display: flex; align-items: center; gap: 10px; }
.drawer-actions .btn.danger.ghost { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.35); color: #fff; }
.drawer-actions .btn.danger.ghost:hover { background: rgba(255,255,255,.26); }
.icon-btn {
  width: 34px; height: 34px; border-radius: 9px;
  background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.3);
  color: #fff; font-size: 20px; line-height: 1;
  display: grid; place-items: center;
}
.icon-btn:hover { background: rgba(255,255,255,.3); }

.tabs { display: flex; gap: 4px; padding: 0 24px; background: #fff; border-bottom: 1px solid var(--line); }
.tab {
  border: 0; background: transparent; padding: 13px 16px;
  font-size: 14px; color: var(--ink-2); position: relative; font-weight: 500;
}
.tab.active { color: var(--brand); font-weight: 700; }
.tab.active::after {
  content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px;
  background: var(--brand-2); border-radius: 3px 3px 0 0;
}
.tab-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  font-size: 11px; line-height: 17px; text-align: center;
  background: var(--brand-soft); color: var(--brand); border-radius: 999px;
}

.drawer-body { flex: 1; overflow-y: auto; padding: 20px 24px 28px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fade .2s ease; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field span { font-size: 12.5px; color: var(--ink-2); font-weight: 600; letter-spacing: .2px; }
.field span i { color: var(--red); font-style: normal; }
.field input, .field textarea {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: .16s;
  width: 100%;
  resize: vertical;
}
.field input:focus, .field textarea:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20, 120, 212, .1); }
.field input:disabled { background: var(--bg-soft); color: var(--ink-3); }
.form-actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; padding-top: 6px; }
.save-hint { font-size: 12.5px; color: var(--teal); }

/* ---------- 上传区 ---------- */
.upload-drop {
  display: flex; align-items: center; gap: 14px;
  border: 1.5px dashed #b9cde4;
  background: #fff;
  border-radius: 12px;
  padding: 18px 20px;
  transition: .18s;
  cursor: pointer;
}
.upload-drop:hover, .upload-drop.drag { border-color: var(--brand-2); background: #f5faff; }
.drop-icon {
  width: 42px; height: 42px; flex: 0 0 42px; border-radius: 11px;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: 20px;
}
.upload-drop b { font-size: 14px; }
.upload-drop p { margin: 3px 0 0; font-size: 12px; color: var(--ink-3); }
.upload-drop > div:nth-child(2) { flex: 1; min-width: 0; }
.upload-drop.compact { padding: 14px 16px; }

.media-progress { margin-top: 12px; display: grid; gap: 6px; }
.progress-row {
  display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-2);
  background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px;
}
.progress-row .bar { flex: 1; height: 5px; background: #e9eef4; border-radius: 4px; overflow: hidden; }
.progress-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, #1478d4, #38a3e0); width: 0; transition: width .2s; }

.media-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 12px;
}
.media-card {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; position: relative;
  transition: .18s;
}
.media-card:hover { border-color: #c7d9ec; box-shadow: 0 10px 24px rgba(16, 42, 67, .1); transform: translateY(-2px); }
.media-thumb {
  width: 100%; aspect-ratio: 4 / 3; background: #eff3f8;
  display: grid; place-items: center; cursor: pointer;
}
.media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-thumb {
  width: 100%; height: 100%;
  background: linear-gradient(140deg, #1d2b3a, #33465c);
  color: #fff; display: grid; place-items: center; gap: 8px;
}
.video-thumb .play {
  width: 46px; height: 46px; border-radius: 50%;
  background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.35);
  display: grid; place-items: center; font-size: 17px;
}
.video-thumb span { font-size: 11px; opacity: .8; letter-spacing: 1px; }
.media-meta { padding: 9px 11px 11px; }
.media-meta b {
  display: block; font-size: 12.5px; font-weight: 500; color: var(--ink-2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.media-meta small { color: var(--ink-3); font-size: 11px; }
.media-actions {
  display: flex; gap: 6px; margin-top: 8px;
}
.media-actions a, .media-actions button {
  flex: 1; height: 28px; border-radius: 7px; font-size: 12px;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--ink-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0;
}
.media-actions a:hover { background: var(--brand-soft); color: var(--brand); border-color: #cfe2f5; }
.media-actions button:hover { background: var(--red-soft); color: var(--red); border-color: #f2cfca; }

/* ---------- 通知单页 ---------- */
.notice-wrap { display: grid; grid-template-columns: 1.15fr .85fr; gap: 16px; align-items: start; }
.notice-preview {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  min-height: 320px; display: grid; place-items: center; overflow: hidden;
}
.notice-preview img { width: 100%; display: block; }
.empty-note { color: var(--ink-3); font-size: 13px; }
.notice-side { display: flex; flex-direction: column; gap: 12px; }
.notice-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ocr-box { background: #fff; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ocr-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.link-btn { border: 0; background: transparent; color: var(--brand); font-size: 12px; }
.ocr-text {
  margin: 0; padding: 12px;
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 12px; line-height: 1.65; color: var(--ink-2);
  max-height: 300px; overflow: auto; white-space: pre-wrap;
}

/* ---------- 弹窗（新增患者） ---------- */
.modal { position: fixed; inset: 0; z-index: 50; }
.modal-mask { position: absolute; inset: 0; background: rgba(12, 28, 44, .45); backdrop-filter: blur(2px); animation: fade .2s; }
.modal-card {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 94vw);
  max-height: 92vh;
  background: var(--bg-soft);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: pop .24s cubic-bezier(.2, .8, .3, 1);
}
@keyframes pop { from { transform: translate(-50%, -46%); opacity: .6; } to { transform: translate(-50%, -50%); opacity: 1; } }
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; background: #fff; border-bottom: 1px solid var(--line);
}
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-head .icon-btn { background: var(--bg-soft); border-color: var(--line); color: var(--ink-2); }
.modal-body { padding: 18px 20px; overflow-y: auto; display: grid; gap: 18px; }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; background: #fff; border-top: 1px solid var(--line);
}
.step { display: flex; gap: 12px; }
.step-no {
  width: 26px; height: 26px; flex: 0 0 26px; border-radius: 50%;
  background: var(--brand-soft); color: var(--brand);
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  margin-top: 1px;
}
.step-body { flex: 1; min-width: 0; }
.step-body h3 { margin: 2px 0 10px; font-size: 14px; font-weight: 600; }
.step-body h3 small { font-weight: 400; color: var(--ink-3); font-size: 12px; }

.ocr-status {
  margin-top: 10px; font-size: 12.5px;
  padding: 9px 12px; border-radius: 9px;
  background: var(--brand-soft); color: var(--brand);
}
.ocr-status.error { background: var(--red-soft); color: var(--red); }
.ocr-status.success { background: var(--teal-soft); color: #0b6f66; }

.ocr-thumb-wrap { margin-top: 12px; display: flex; gap: 12px; align-items: flex-start; }
.ocr-thumb-wrap img {
  width: 132px; height: 168px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line); background: #fff;
}
.ocr-fields { display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-2); flex: 1; }
.ocr-fields span { color: var(--teal); font-weight: 600; }

.raw-details { margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.raw-details summary { cursor: pointer; color: var(--brand); }
.raw-details pre {
  background: #fff; border: 1px solid var(--line); border-radius: 9px;
  padding: 10px; max-height: 180px; overflow: auto;
  white-space: pre-wrap; font-size: 12px; line-height: 1.6; margin: 8px 0 0;
}

/* ---------- 导出弹窗 ---------- */
.export-card .modal-body { gap: 13px; }
.modal-tip { margin: 0; font-size: 12.5px; color: var(--ink-3); line-height: 1.65; }
.export-group {
  background: #fff; border: 1px solid var(--line);
  border-radius: 11px; padding: 12px 14px;
}
.export-group h3 { margin: 0 0 9px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.range-row { display: flex; align-items: center; gap: 9px; }
.range-row input {
  flex: 1; min-width: 0; height: 36px; border: 1px solid var(--line);
  border-radius: 9px; padding: 0 10px; background: #fff; font-size: 13px; outline: none;
}
.range-row input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(20, 120, 212, .1); }
.export-quick { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- 灯箱 / 视频 ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(8, 18, 28, .93);
  display: grid; place-items: center; padding: 40px;
}
.lightbox img { max-width: 94vw; max-height: 86vh; border-radius: 8px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.lightbox-close {
  position: absolute; top: 18px; right: 24px;
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.12);
  color: #fff; font-size: 22px;
}
.lightbox-download {
  position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  color: #fff; border: 1px solid rgba(255,255,255,.4);
  padding: 9px 18px; border-radius: 999px; font-size: 13px;
  background: rgba(255,255,255,.12);
}

.video-modal { position: fixed; inset: 0; z-index: 60; background: rgba(8, 18, 28, .92); display: grid; place-items: center; padding: 24px; }
.video-card { width: min(960px, 96vw); background: #0f1a26; border-radius: 14px; overflow: hidden; box-shadow: var(--shadow-lg); }
.video-card header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; color: #fff; font-size: 13.5px; background: rgba(255,255,255,.05);
}
.video-card header > div { display: flex; align-items: center; gap: 8px; }
.video-card video { width: 100%; max-height: 78vh; display: block; background: #000; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 34px; transform: translateX(-50%);
  z-index: 80;
  background: rgba(22, 35, 47, .95); color: #fff;
  padding: 11px 20px; border-radius: 999px;
  font-size: 13px; box-shadow: 0 12px 30px rgba(0,0,0,.2);
  animation: toastIn .22s ease;
}
.toast.err { background: #a3281c; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ---------- 响应式 ---------- */
@media (max-width: 1080px) {
  .table-head, .patient-row { grid-template-columns: 104px 86px 100px 100px minmax(120px, 1fr) 78px 82px 96px; }
}

@media (max-width: 900px) {
  .topbar { padding: 12px 16px; gap: 10px; flex-wrap: wrap; }
  .brand-text p { display: none; }
  .top-actions { flex: 1 1 100%; justify-content: space-between; }
  .search { max-width: none; width: auto; flex: 1; }
  .btn-label { display: none; }
  #btnAdd { width: 42px; padding: 0; }
  main { padding: 16px 14px 6px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 11px 13px; }
  .stat b { font-size: 19px; }
  .table-head { display: none; }
  .table-wrap { overflow: visible; }
  .table-head, .patient-list { min-width: 0; }
  .patient-list { padding: 8px 10px; display: grid; gap: 10px; }
  .patient-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "name status"
      "no no"
      "meta meta"
      "proc proc"
      "notes notes"
      "actions actions";
    gap: 6px;
    padding: 12px 12px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
  }
  .p-name { grid-area: name; }
  .p-no { grid-area: no; }
  .patient-row .p-date, .patient-row .p-media, .patient-row .p-bed, .patient-row .p-diag { display: none; }
  .p-proc { grid-area: proc; color: var(--ink-2); white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .p-notes { grid-area: notes; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .p-status { grid-area: status; justify-self: end; }
  .p-meta { grid-area: meta; font-size: 12px; color: var(--ink-3); display: flex; gap: 10px; flex-wrap: wrap; }
  .row-actions { grid-area: actions; justify-content: flex-start; margin-top: 4px; }
  .filter-bar { gap: 10px; padding: 10px 12px; }
  .filter-label { display: none; }
  .filter-tail { margin-left: 0; flex: 1 1 100%; justify-content: space-between; }
  .date-input { flex: 1; min-width: 0; }
  .mobile-only { display: block; }
  .drawer-panel { width: 100%; }
  .drawer-body { padding: 16px 14px 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid.three { grid-template-columns: 1fr; }
  .notice-wrap { grid-template-columns: 1fr; }
  .media-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
  .modal-card { width: calc(100vw - 24px); max-height: 88vh; }
  .ocr-thumb-wrap img { width: 104px; height: 132px; }
  .tab { padding: 12px 12px; font-size: 13.5px; }
}

@media (max-width: 560px) {
  .brand-text h1 { font-size: 15.5px; }
  .logo { width: 36px; height: 36px; flex-basis: 36px; font-size: 16px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat-icon { width: 34px; height: 34px; flex-basis: 34px; font-size: 12px; }
  .stat b { font-size: 18px; }
  .panel-head { padding: 13px 14px; }
}
/* ================= v1.2 追加样式 ================= */

/* 状态徽标：手术日 */
.badge.op { background: var(--red-soft); color: var(--red); }

/* 手术日期 (今日/明日/昨日) 标注 */
.day-tag { margin-left: 1px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.day-tag.today { color: #d92b1f; }
.day-tag.tomorrow { color: #1668c9; }
.day-tag.yesterday { color: #1a8a4a; }
.p-date .day-tag { display: inline; }

/* 床号单元格 */
.p-bed { font-size: 13px; color: var(--ink-2); }
.p-bed .bed-unit { font-size: 11px; color: var(--ink-3); margin-left: 1px; }

/* ---------- 顶栏用户菜单 ---------- */
.user-menu { position: relative; flex: 0 0 auto; }
.user-chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 38px; padding: 0 11px 0 6px;
  border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--ink-2); font-size: 13px; font-weight: 600;
  cursor: pointer; transition: .16s;
}
.user-chip:hover { border-color: #bcd8f5; color: var(--brand); }
.user-avatar {
  width: 26px; height: 26px; border-radius: 50%; flex: 0 0 26px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 700;
}
.user-chip .caret { font-size: 10px; color: var(--ink-3); }
.user-dropdown {
  position: absolute; right: 0; top: 46px; z-index: 40;
  min-width: 148px; padding: 6px;
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 14px 34px rgba(16, 42, 67, .16);
  display: grid; gap: 2px;
}
.user-dropdown.hidden { display: none; }
.menu-item {
  text-align: left; padding: 9px 11px; border: 0; border-radius: 8px;
  background: transparent; color: var(--ink); font-size: 13.5px; cursor: pointer;
}
.menu-item:hover { background: var(--bg-soft); }
.menu-item.danger { color: var(--red); }
.menu-item.danger:hover { background: var(--red-soft); }

/* ---------- 登录页 ---------- */
.login-screen {
  position: fixed; inset: 0; z-index: 200;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(1200px 620px at 12% -6%, #d9e9fb 0%, rgba(217, 233, 251, 0) 62%),
    radial-gradient(900px 520px at 96% 104%, #e3f4f1 0%, rgba(227, 244, 241, 0) 60%),
    linear-gradient(160deg, #f3f7fc 0%, #e7eef7 100%);
  padding: 20px;
}
.login-screen.hidden { display: none; }
.login-panel {
  width: 100%; max-width: 372px;
  background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 34px 30px 26px;
  box-shadow: 0 24px 60px rgba(16, 42, 67, .16);
  text-align: center;
}
.login-logo {
  width: 54px; height: 54px; margin: 0 auto 14px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-2) 100%);
  color: #fff; font-size: 26px; font-weight: 700; letter-spacing: 1px;
  box-shadow: 0 10px 22px rgba(11, 92, 171, .28);
}
.login-panel h1 { margin: 0; font-size: 20px; letter-spacing: .5px; color: var(--ink); }
.login-sub { margin: 7px 0 24px; font-size: 12.5px; color: var(--ink-3); }
.login-panel form { display: grid; gap: 14px; text-align: left; }
.login-panel form > label { display: grid; gap: 6px; font-size: 12.5px; color: var(--ink-2); font-weight: 600; }
.login-panel form input {
  height: 42px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-soft);
  font-size: 14.5px; color: var(--ink); letter-spacing: .5px;
}
.login-panel form input:focus { outline: 0; border-color: var(--brand-2); background: #fff; box-shadow: 0 0 0 3px rgba(20, 120, 212, .12); }
.login-btn { height: 44px; width: 100%; font-size: 15px; letter-spacing: 4px; margin-top: 2px; }
.login-error { min-height: 16px; font-size: 12.5px; color: var(--red); }
.login-foot { margin: 18px 0 0; font-size: 11.5px; color: var(--ink-3); }

/* ---------- 账号管理 ---------- */
.account-card { width: 560px; }
.account-list-head, .account-row {
  display: grid; grid-template-columns: .95fr .8fr 1fr .8fr 62px;
  gap: 10px; align-items: center;
}
.account-list-head {
  font-size: 12px; color: var(--ink-3); font-weight: 600;
  padding: 0 10px 8px; border-bottom: 1px solid var(--line);
}
.account-list { display: grid; gap: 6px; max-height: 300px; overflow-y: auto; }
.account-row {
  padding: 9px 10px; border-radius: 9px; background: var(--bg-soft);
  font-size: 13.5px;
}
.account-row .acc-name { font-weight: 600; display: flex; align-items: center; gap: 6px; }
.account-row .acc-realname { font-weight: 600; color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row .acc-pass { font-family: ui-monospace, Consolas, monospace; color: var(--ink-2); letter-spacing: .5px; }
.account-row .acc-time { font-size: 12px; color: var(--ink-3); }
.account-row .acc-del {
  height: 28px; padding: 0 9px; font-size: 12px;
  border: 1px solid #f0c4bd; color: var(--red); background: #fff; border-radius: 7px; cursor: pointer;
}
.account-row .acc-del:hover { background: var(--red-soft); }
.account-row .acc-del:disabled { opacity: .45; cursor: not-allowed; border-color: var(--line); color: var(--ink-3); background: var(--bg-soft); }
.tag-admin { font-size: 10.5px; padding: 1px 6px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.account-add { border-top: 1px dashed var(--line); padding-top: 14px; display: grid; gap: 10px; }
.account-add h3 { margin: 0; font-size: 13.5px; color: var(--ink-2); }
.account-add-row { display: flex; gap: 9px; }
.account-add-row input {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: 9px; background: var(--bg-soft); font-size: 13px;
}
.account-add-row input:focus { outline: 0; border-color: var(--brand-2); background: #fff; }

/* ---------- 修改密码 ---------- */
.pwd-card { width: 400px; }
.pwd-card .modal-body { gap: 12px; }

/* 日期校验提示 */
.field input.invalid { border-color: #e2a79f; background: #fff8f7; }
.date-hint { font-size: 11.5px; color: var(--red); margin: -2px 0 0; }

@media (max-width: 720px) {
  .user-chip { padding: 0 8px; }
  .user-name { display: none; }
  .account-card, .pwd-card { width: calc(100vw - 24px); }
  .account-list-head, .account-row { grid-template-columns: 1fr 1fr 58px; }
  .account-row .acc-realname, .account-row .acc-time,
  .account-list-head span:nth-child(2), .account-list-head span:nth-child(4) { display: none; }
  .account-add-row { flex-wrap: wrap; }
  .account-add-row input { flex: 1 1 100%; }
}

/* ---------- 费用三栏 ---------- */
.cost-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.cost-grid .field { min-width: 0; }
@media (max-width: 720px) {
  .cost-grid { grid-template-columns: 1fr; }
}

/* ---------- 诊断/术式关键词筛选 ---------- */
.filter-bar-keywords { border-bottom: 1px solid var(--line); background: #f7fbff; row-gap: 8px; }
.text-input {
  border: 1px solid var(--line); border-radius: 9px; height: 32px;
  padding: 0 10px; font-size: 12.5px; background: #fff; color: var(--ink-2);
  outline: none; width: 232px;
}
.text-input:focus { border-color: var(--brand-2); }
.text-input::placeholder { color: #9aa9b8; }
@media (max-width: 720px) {
  .text-input { width: 100%; }
  .filter-bar-keywords .filter-group { width: 100%; }
  .filter-bar-keywords .filter-tail { display: none; }
}
