/* ===== 血透中心月度登记 · 设计系统 ===== */
:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --border: #e2e8f0;
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #94a3b8;
  --primary: #0d9488;
  --primary-strong: #0f766e;
  --primary-soft: #ccfbf1;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --ok: #16a34a;
  --ok-soft: #f0fdf4;
  --info-soft: #eff6ff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .12);
  --shadow-lg: 0 24px 60px -24px rgba(15, 23, 42, .35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 顶部栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-icon {
  font-size: 30px; width: 46px; height: 46px; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--primary-soft); border-radius: 12px;
}
.brand-text h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.brand-text p { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.month-picker { display: flex; align-items: center; gap: 8px; }
.month-picker-label { font-size: 13px; color: var(--text-2); }
.month-picker input[type=month] {
  font-family: var(--font); font-size: 14px; font-weight: 600;
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none;
}
.month-picker input[type=month]:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  padding: 10px 16px; border-radius: var(--radius-sm); border: 1px solid transparent;
  cursor: pointer; transition: all .15s ease; white-space: nowrap;
}
.btn-icon { font-size: 15px; }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 4px 12px -4px rgba(13,148,136,.5); }
.btn-primary:hover { background: var(--primary-strong); }
.btn-primary:active { transform: translateY(1px); }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--danger-soft); color: var(--danger); }
.btn-danger:hover { background: #fee2e2; }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: none; background: transparent; border-radius: 10px;
  font-size: 16px; color: var(--text-2); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); }

/* ---------- 容器 ---------- */
.container { max-width: 1180px; margin: 0 auto; padding: 22px 20px 90px; }

/* ---------- 统计卡片 ---------- */
.stats-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px;
}
.stat-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat-card::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 4px;
}
.stat-primary::before { background: var(--primary); }
.stat-total::before { background: #6366f1; }
.stat-warn::before { background: var(--warn); }
.stat-info::before { background: #0ea5e9; }
.stat-value { font-size: 30px; font-weight: 800; letter-spacing: -.02em; }
.stat-label { font-size: 13px; color: var(--text-3); margin-top: 2px; }

/* ---------- 工具栏 ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.search-box {
  flex: 1; max-width: 360px; display: flex; align-items: center; gap: 8px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0 12px; height: 42px;
}
.search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.search-icon { font-size: 14px; opacity: .6; }
.search-box input {
  flex: 1; border: none; outline: none; font-family: var(--font); font-size: 14px; background: transparent; color: var(--text);
}
.search-clear { border: none; background: none; color: var(--text-3); cursor: pointer; font-size: 14px; }
.toolbar-right { display: flex; align-items: center; gap: 12px; }
.count-hint { font-size: 13px; color: var(--text-3); }

/* ---------- 患者列表 ---------- */
.patient-list { display: flex; flex-direction: column; gap: 10px; }

.patient-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); cursor: pointer;
  display: flex; align-items: center; gap: 14px; transition: all .15s ease;
}
.patient-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 6px 20px -8px rgba(15,23,42,.16); }
.patient-card.is-new { border-left: 4px solid var(--danger); }
.patient-card.is-out { border-left: 4px solid var(--warn); }

.pc-avatar {
  width: 44px; height: 44px; flex-shrink: 0; border-radius: 12px;
  display: grid; place-items: center; font-weight: 700; font-size: 16px; color: #fff;
  background: linear-gradient(135deg, #14b8a6, #0d9488);
}
.pc-avatar.f { background: linear-gradient(135deg, #f472b6, #ec4899); }

.pc-main { flex: 1; min-width: 0; }
.pc-name-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pc-name { font-size: 16px; font-weight: 700; }
.pc-badges { display: flex; gap: 5px; flex-wrap: wrap; }
.badge {
  font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 99px;
  background: var(--surface-2); color: var(--text-2); border: 1px solid var(--border);
}
.badge-new { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.badge-out { background: var(--warn-soft); color: var(--warn); border-color: #fde68a; }
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.pc-sub { font-size: 12.5px; color: var(--text-3); margin-top: 3px; display: flex; gap: 12px; flex-wrap: wrap; }
.pc-sub span { white-space: nowrap; }

.pc-meta { flex-shrink: 0; display: flex; align-items: center; gap: 10px; }
.pc-checks { display: flex; flex-direction: column; gap: 3px; align-items: flex-end; }
.pc-check {
  font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 500;
  background: var(--surface-2); color: var(--text-3); border: 1px solid var(--border);
}
.pc-check.done { background: var(--ok-soft); color: var(--ok); border-color: #bbf7d0; }
.pc-chevron { color: var(--text-3); font-size: 16px; }

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center; padding: 60px 20px; color: var(--text-3);
  background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius);
}
.empty-icon { font-size: 44px; margin-bottom: 10px; }
.empty-state p { font-size: 15px; }
.empty-sub { font-size: 13px; margin-top: 4px; opacity: .7; }
.hidden { display: none !important; }

/* ---------- 抽屉 ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 50;
  opacity: 0; pointer-events: none; transition: opacity .2s ease;
  backdrop-filter: blur(2px);
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100%);
  background: var(--surface); z-index: 60; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .25s cubic-bezier(.32,.72,.24,1);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.drawer-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.drawer-title > span { font-size: 22px; }
.drawer-title h2 { font-size: 17px; font-weight: 700; }
.drawer-title p { font-size: 12px; color: var(--text-3); }

.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; -webkit-overflow-scrolling: touch; }

/* 分组折叠 */
.group { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 12px; overflow: hidden; }
.group-header {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px;
  background: var(--surface-2); cursor: pointer; user-select: none;
}
.group-header .g-icon { font-size: 18px; }
.group-header .g-name { font-weight: 700; font-size: 14px; flex: 1; }
.group-header .g-status { font-size: 11px; color: var(--text-3); }
.group-header .g-caret { color: var(--text-3); transition: transform .2s ease; font-size: 12px; }
.group.collapsed .g-caret { transform: rotate(-90deg); }
.group-body { padding: 14px 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.group.collapsed .group-body { display: none; }

.field { display: flex; flex-direction: column; gap: 5px; }
.field.full { grid-column: 1 / -1; }
.field-label { font-size: 12.5px; color: var(--text-2); font-weight: 500; }
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-label .hint { color: var(--text-3); font-weight: 400; font-size: 11px; margin-left: 4px; }
.field input, .field select, .field textarea {
  font-family: var(--font); font-size: 15px; padding: 10px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); outline: none; width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance: none; appearance: none;
}
.field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field textarea { min-height: 72px; resize: vertical; }
.field input[type=date], .field input[type=month] { min-height: 42px; }

/* 抽屉底部 */
.drawer-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border);
  background: var(--surface);
}
.drawer-footer-right { display: flex; gap: 10px; }
.drawer-footer .btn { min-width: 84px; justify-content: center; }

/* ---------- 悬浮按钮（移动端） ---------- */
.fab {
  position: fixed; right: 20px; bottom: 24px; z-index: 45;
  width: 56px; height: 56px; border-radius: 50%; border: none;
  background: var(--primary); color: #fff; font-size: 26px; cursor: pointer;
  box-shadow: 0 8px 24px -6px rgba(13,148,136,.6);
  display: none; align-items: center; justify-content: center;
  transition: transform .15s ease;
}
.fab:active { transform: scale(.92); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 14px; font-weight: 500; z-index: 100; opacity: 0; pointer-events: none;
  transition: all .25s ease; box-shadow: var(--shadow-lg); max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-actions .month-picker-label { display: none; }
}
@media (max-width: 640px) {
  .topbar-inner { padding: 12px 14px; flex-wrap: wrap; }
  .brand-text h1 { font-size: 15px; }
  .brand-text p { font-size: 11px; }
  .brand-icon { width: 40px; height: 40px; font-size: 24px; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .month-picker input[type=month] { flex: 1; }
  .btn#exportBtn { padding: 10px 14px; }
  .container { padding: 16px 12px 90px; }
  .stat-value { font-size: 24px; }
  .stat-card { padding: 14px 16px; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .toolbar-right { justify-content: space-between; }
  #addBtn { display: none; }
  .fab { display: flex; }
  .pc-avatar { width: 40px; height: 40px; font-size: 15px; }
  .pc-meta .pc-chevron { font-size: 14px; }
  .pc-check { font-size: 10px; }
  .drawer { width: 100%; }
  .group-body { grid-template-columns: 1fr; }
}

/* ===== 登录页 ===== */
.login-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: linear-gradient(135deg, #ccfbf1, #eef2f7, #f0fdf4);
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
.login-overlay[hidden] { display: none; }
.login-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: 0 16px 48px -16px rgba(15, 23, 42, .25);
  padding: 36px 30px; width: 100%; max-width: 400px;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-icon { font-size: 42px; display: block; margin-bottom: 10px; }
.login-header h2 { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.login-header p { font-size: 14px; color: var(--text-3); }
.login-form { display: flex; flex-direction: column; gap: 16px; }
.login-error { font-size: 13px; color: var(--danger); text-align: center; min-height: 20px; }
.btn-full { width: 100%; justify-content: center; padding: 12px; font-size: 15px; }

/* ===== 用户下拉 ===== */
.user-dropdown { position: relative; }
.user-btn { padding: 10px 14px; }
.dropdown-menu {
  position: absolute; top: 110%; right: 0; min-width: 160px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg); z-index: 50;
  padding: 6px; overflow: hidden;
}
.dropdown-menu[hidden] { display: none; }
.dropdown-item {
  display: block; width: 100%; padding: 10px 14px; border: none; background: none;
  font-family: var(--font); font-size: 14px; color: var(--text); text-align: left;
  border-radius: 8px; cursor: pointer; transition: background .1s;
}
.dropdown-item:hover { background: var(--surface-2); }
.logout-item { color: var(--danger); }
.logout-item:hover { background: var(--danger-soft); }
.dropdown-divider { margin: 6px 0; border: none; border-top: 1px solid var(--border); }

/* ===== 弹窗（改密码等）===== */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 70;
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.modal-backdrop[hidden] { display: none; }
.modal-card {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  z-index: 71;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg);
  width: calc(100% - 40px); max-width: 420px; overflow: hidden;
}
.modal-card[hidden] { display: none; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface-2);
}
.modal-footer .btn { min-width: 80px; justify-content: center; }

/* ===== 审计行 ===== */
.pc-audit {
  font-size: 11px; color: var(--text-3); margin-top: 4px;
  padding-top: 4px; border-top: 1px dashed var(--border);
}

/* ===== app-root hidden 状态 ===== */
.app-root[hidden] { display: none; }
