:root {
  --sb-w: 230px;
  --primary: #2C6ECB;
  --sidebar-bg: #1e2f4d;
}
body { background: #f2f5f9; font-family: "PingFang SC","Microsoft YaHei","Segoe UI",sans-serif; }

/* ---------- 布局 ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sb-w); flex-shrink: 0; background: var(--sidebar-bg); color: #cdd7e6;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.brand i { font-size: 28px; color: #5b9cf0; }
.brand-name { font-weight: 700; color: #fff; font-size: 15px; }
.brand-sub { font-size: 11px; color: #8fa3c0; }
.side-nav { padding: 12px 10px; flex: 1; }
.side-nav .nav-link { color: #cdd7e6; border-radius: 8px; padding: 9px 14px; margin-bottom: 2px; font-size: 14px; }
.side-nav .nav-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.side-nav .nav-link.active { background: var(--primary); color: #fff; }
.nav-divider { border-top: 1px solid rgba(255,255,255,.1); margin: 10px 6px; }
.side-foot { padding: 14px 16px; font-size: 11px; color: #6d80a0; border-top: 1px solid rgba(255,255,255,.08); }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid #e5eaf1; padding: 10px 22px;
  display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-weight: 700; font-size: 15px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.content { padding: 20px 22px; flex: 1; }
.content > .alert { margin-bottom: 14px; }

/* ---------- 角色/状态徽章 ---------- */
.role-badge { font-size: 12px; }
.role-admin { background: #2c3e50; color: #fff; }
.role-cra { background: #b07d2b; color: #fff; }
.role-crc { background: #2C6ECB; color: #fff; }
.role-pm { background: #6a3fb0; color: #fff; }
.role-doctor { background: #4a7d2c; color: #fff; }

/* ---------- 统计卡（可点击跳转） ---------- */
a .stat-card { height: 100%; transition: .15s; }
a:hover .stat-card { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,42,83,.15); }
.stat-card { background: #fff; border-radius: 12px; padding: 16px; display: flex; gap: 14px; align-items: center; box-shadow: 0 1px 3px rgba(16,42,83,.08); }
.stat-ico { width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 22px; }
.stat-blue .stat-ico { background: #e7f0fd; color: var(--primary); }
.stat-teal .stat-ico { background: #e0f5f1; color: #12866f; }
.stat-orange .stat-ico { background: #fdf0e0; color: #c07b12; }
.stat-red .stat-ico { background: #fde5e5; color: #c0392b; }
.stat-num { font-size: 24px; font-weight: 800; line-height: 1.1; }
.stat-label { font-size: 12px; color: #7b8aa0; }
.mini-stat { background: #fff; border-radius: 10px; padding: 12px 16px; box-shadow: 0 1px 3px rgba(16,42,83,.08); }
.mini-stat .num { font-size: 22px; font-weight: 800; color: var(--primary); }
.mini-stat .lbl { font-size: 12px; color: #7b8aa0; }
.project-card { border: none; border-radius: 12px; transition: .15s; }
.project-card:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(16,42,83,.12) !important; }

/* ---------- 项目页 ---------- */
.project-tabs .nav-link { color: #4a5a70; font-size: 14px; }
.project-tabs .nav-link.active { background: var(--primary); }

/* ---------- CRF 录入 ---------- */
.crf-label { font-weight: 600; font-size: 13.5px; color: #33475e; margin-bottom: 4px; }
.card { border: none; border-radius: 10px; }
.card-header { border-bottom: 1px solid #eef1f6; background: #fff; }
.flash-ok { border-color: #2fa876 !important; box-shadow: 0 0 0 .2rem rgba(47,168,118,.2) !important; background: #f0fff8 !important; }
.ocr-card .card-header { color: var(--primary); }
.ocr-table { max-height: 260px; overflow-y: auto; }

/* ---------- 附件 ---------- */
.att-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 8px; }
.att-item img { width: 100%; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid #e3e9f2; }
.att-item:hover img { border-color: var(--primary); }

/* ---------- 疑问 ---------- */
.query-item { border-left: 3px solid #e74c3c; background: #fdf7f6; border-radius: 0 8px 8px 0; padding: 8px 10px; margin-bottom: 8px; }
.query-item.closed { border-left-color: #95a5a6; background: #f6f7f8; }

/* ---------- 审计 ---------- */
.audit-list { max-height: 420px; overflow-y: auto; }
.audit-item { padding: 7px 0; border-bottom: 1px dashed #eef1f6; }
.audit-item:last-child { border-bottom: none; }

/* ---------- 登录页 ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #1e2f4d 0%, #2C6ECB 100%); padding: 16px; }
.login-card { background: #fff; border-radius: 16px; padding: 36px 34px; width: 100%; max-width: 420px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25); }
.login-head { text-align: center; margin-bottom: 22px; }
.login-head i { font-size: 44px; color: var(--primary); }
.login-head h2 { font-size: 20px; font-weight: 800; margin-top: 8px; }
.login-head p { font-size: 12.5px; margin-bottom: 0; }
.demo-accounts { font-size: 12px; }
.login-wrap { flex-direction: column; }
.login-foot { margin-top: 18px; font-size: 11.5px; color: rgba(255,255,255,.72); text-align: center;
  line-height: 1.7; max-width: 460px; }
.login-foot .brand-line { font-weight: 600; color: rgba(255,255,255,.88); }
@media (max-width: 480px) {
  .login-card { padding: 26px 20px; }
  .login-head i { font-size: 36px; }
  .login-head h2 { font-size: 17px; }
  .login-foot { font-size: 10.5px; }
}

/* ---------- 全站页脚版权 ---------- */
.app-foot { text-align: center; font-size: 11.5px; color: #9aa8bd; padding: 18px 12px 10px;
  border-top: 1px solid #eef2f7; margin-top: 22px; line-height: 1.7; }
.app-foot b { color: #7b8aa0; font-weight: 600; }
@media (max-width: 768px) { .app-foot { font-size: 10.5px; padding: 14px 8px 8px; } }

@media (max-width: 768px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; overflow-x: auto; }
  .brand { padding: 10px 12px; border-bottom: none; }
  .brand i { font-size: 22px; }
  .brand-name { font-size: 13px; white-space: nowrap; }
  .brand-sub { display: none; }
  .side-nav { display: flex; flex-direction: row !important; padding: 6px; align-items: center; }
  .side-nav .nav-link { white-space: nowrap; padding: 7px 11px; font-size: 13px; }
  .side-foot, .nav-divider { display: none; }
  .content { padding: 12px; }
  .topbar { padding: 8px 12px; }
  .topbar-title { font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
  .stat-num { font-size: 19px; }
  .stat-ico { width: 36px; height: 36px; font-size: 17px; }
  .mini-stat .num { font-size: 18px; }
  h5 { font-size: 16px; }
  .btn { --bs-btn-padding-x: .6rem; }
  .btn-sm { --bs-btn-padding-x: .5rem; }
  /* 标签页横向滑动（CRF分组多时） */
  .nav-tabs, .project-tabs, .btn-group { flex-wrap: nowrap !important; overflow-x: auto; }
  .nav-tabs .nav-link, .project-tabs .nav-link { white-space: nowrap; }
  /* 表格横向滚动 */
  .table { min-width: 560px; margin-bottom: 0; }
  .card-body .form-check-inline { margin-right: .5rem; }
  .modal-dialog { margin: .5rem; }
  .att-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
  .audit-list { max-height: none; }
}

/* 平板 / 小屏笔记本 */
@media (min-width: 769px) and (max-width: 1100px) {
  .sidebar { width: 200px; }
  .content { padding: 16px; }
}

/* 电脑宽屏 */
@media (min-width: 1400px) {
  .content { padding: 24px 32px; }
  .sidebar { width: 250px; }
}

/* ============ 是/否 等选项控件：选中态高亮（显著提升可见性） ============ */
.choice-group { display: flex; flex-wrap: wrap; gap: .4rem .5rem; align-items: center; }
.choice-pill {
  display: inline-flex; align-items: center; justify-content: center; gap: .3rem;
  min-width: 76px; padding: .42rem 1rem; margin: 0;
  border: 2px solid #c5cfdf; border-radius: 999px;
  background: #fff; color: #4a5875; font-weight: 700; font-size: 14px;
  cursor: pointer; user-select: none; transition: all .15s ease;
}
.choice-pill::before { content: '\25CB'; font-size: 15px; color: #a3aec2; font-weight: 400; }
.choice-pill:hover { border-color: #1565C0; color: #1565C0; background: #f2f7ff; }
.choice-pill.multi::before { content: '\2610'; font-size: 16px; }
/* 选中：实心蓝底白字 + 打勾 */
.btn-check:checked + .choice-pill {
  background: #1565C0; border-color: #0D47A1; color: #fff;
  box-shadow: 0 3px 10px rgba(21, 101, 192, .38);
  transform: scale(1.04);
}
.btn-check:checked + .choice-pill::before { content: '\2713'; color: #fff; font-weight: 700; }
/* 多选：选中为实心绿底白字 + 打勾方框 */
.btn-check:checked + .choice-pill.multi {
  background: #0F7B3F; border-color: #0a5c2e; color: #fff;
  box-shadow: 0 3px 10px rgba(15, 123, 63, .35);
}
.btn-check:checked + .choice-pill.multi::before { content: '\2612'; }
.choice-pill.flash-ok, .btn-check:checked + .choice-pill.flash-ok {
  animation: pillFlash 1.2s ease;
}
@keyframes pillFlash {
  0%, 100% { box-shadow: 0 3px 10px rgba(21,101,192,.38); }
  30% { box-shadow: 0 0 0 6px rgba(255,193,7,.65); }
  60% { box-shadow: 0 0 0 6px rgba(255,193,7,.25); }
}
/* CRA 只读视图中的已选值同样高亮 */
.ro-choice {
  display: inline-block; padding: .25rem .9rem; margin: 0 .3rem .3rem 0;
  border-radius: 999px; background: #1565C0; color: #fff;
  font-weight: 700; font-size: 13.5px; box-shadow: 0 2px 6px rgba(21,101,192,.3);
}
.ro-choice::before { content: '\2713 '; }
.ro-choice.multi { background: #0F7B3F; box-shadow: 0 2px 6px rgba(15,123,63,.3); }

/* 项目内页签 */
.project-tabs .nav-link { font-size: 14px; }
.fmt-card { transition: all .15s ease; }

/* ============ 数据疑问标记与快速定位 ============ */
.crf-field { border-radius: 8px; padding: 6px 8px; margin-bottom: 2px; transition: background .2s; }
.crf-field.has-query {
  background: #fff5f5;
  border-left: 4px solid #dc3545;
  box-shadow: inset 0 0 0 1px #f5c2c7;
}
.crf-field .q-badge { font-size: 11.5px; vertical-align: middle; }
.q-tip { border-top: 1px dashed #f1b0b7; padding-top: 6px; }
.q-tip-item { font-size: 12.5px; color: #8a2b2b; background: #fff; border: 1px solid #f5c2c7;
  border-radius: 6px; padding: 6px 8px; margin-bottom: 5px; }
.qfix-form { max-width: 420px; }
.nav-tabs .nav-link.tab-has-query { color: #b02a37; font-weight: 700; }
.nav-tabs .nav-link.tab-has-query.active { background: #fff; border-bottom-color: #dc3545; }
.q-dot { font-size: 10.5px; padding: .2em .45em; }
.crf-field.q-flash { animation: qFlash 1.2s ease 0s 2; }
@keyframes qFlash {
  0%,100% { background: #fff5f5; }
  35% { background: #ffe08a; box-shadow: 0 0 0 3px rgba(255,193,7,.55); }
}
.review-bar {
  display: flex; flex-wrap: wrap; gap: .5rem; align-items: center;
  background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 8px; padding: .6rem .75rem;
}
/* 剂量数字输入（两位小数，直接键入） */
.dose-wrap { max-width: 360px; }
/* 日期时间选择：日历 + 时/分下拉（分钟支持 0-59 任意值，可直接键入） */
.dt-picker .form-control, .dt-picker .form-select { min-height: 38px; }
.dt-minbox { display: flex; gap: .25rem; }
.dt-minbox .dt-min { flex: 1 1 auto; min-width: 0; }
.dt-minbox .dt-min-manual {
  flex: 0 0 62px; width: 62px; text-align: center; padding-left: .25rem; padding-right: .25rem;
}
.dt-minbox .dt-min-manual::-webkit-outer-spin-button,
.dt-minbox .dt-min-manual::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.dt-minbox .dt-min-manual { -moz-appearance: textfield; }
/* 用药记录逐天添加行 */
.med-day {
  border: 1px solid #e3e8ef; border-radius: 10px; padding: .65rem .85rem .85rem;
  margin-bottom: .6rem; background: #fcfdff;
}
.med-day-head { border-bottom: 1px dashed #e3e8ef; margin-bottom: .55rem; }
.med-day-collapsed { display: none; }
/* 保存后「已定位到下一待录项」提示条 */
.save-next-tip {
  background: #eaf3ff; border: 1px solid #bcd7fb; color: #17457f; border-radius: 8px;
  padding: .5rem .75rem; margin-bottom: .75rem; font-size: .875rem;
  transition: opacity .5s ease;
}
/* 可点击的统计数字 */
.mini-stat a, .stat-link { text-decoration: none; color: inherit; }
.mini-stat a:hover .num, .stat-link:hover { color: #1565C0; }

/* ===== 项目成员 × 研究中心 分配矩阵 ===== */
.center-grid td, .center-grid th { vertical-align: middle; }
.center-chip {
  display: inline-flex; align-items: center; gap: .25rem;
  border: 1px solid #d7dee8; border-radius: 999px; padding: .1rem .45rem .1rem .35rem;
  cursor: pointer; font-size: .78rem; background: #fff; user-select: none;
}
.center-chip.on { background: #e7f0ff; border-color: #9dc0f5; color: #14478c; font-weight: 600; }
.center-chip input { cursor: pointer; }
.center-chip input:disabled { cursor: not-allowed; }
.scope-table td, .scope-table th { vertical-align: middle; }
.scope-table .form-select-sm { min-width: 120px; }
