/* 肺栓塞病例收集平台 —— 样式（无构建、无依赖） */
:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --blue-soft: #eff6ff;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --green: #16a34a;
  --green-soft: #ecfdf5;
  --orange: #d97706;
  --orange-soft: #fffbeb;
  --red: #dc2626;
  --red-soft: #fef2f2;
  --purple: #7c3aed;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei",
               "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; }
button { font-family: inherit; font-size: 13px; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 13px; color: var(--text); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; }

/* ---------- 布局 ---------- */
#app { display: flex; min-height: 100vh; }
#sidebar {
  width: 208px; flex: 0 0 208px; background: #0f172a; color: #cbd5e1;
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { padding: 18px 16px 12px; border-bottom: 1px solid #1e293b; }
.brand .t1 { color: #fff; font-size: 15px; font-weight: 600; letter-spacing: .3px; }
.brand .t2 { color: #64748b; font-size: 11px; margin-top: 3px; }
#nav { padding: 10px 8px; flex: 1; overflow: auto; }
.nav-item {
  display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 8px;
  color: #cbd5e1; cursor: pointer; margin-bottom: 3px; font-size: 13.5px; user-select: none;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; }
.sidebar-foot { padding: 10px 14px 14px; border-top: 1px solid #1e293b; font-size: 11px; color: #64748b; }

#main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#topbar {
  height: 56px; background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 18px; gap: 12px; position: sticky; top: 0; z-index: 20;
}
#topbar .title { font-size: 15px; font-weight: 600; }
#content { padding: 18px; flex: 1; }

/* ---------- 卡片/面板 ---------- */
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.panel + .panel { margin-top: 14px; }
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.panel-head h3 { font-size: 14.5px; }
.panel-body { padding: 14px 16px; }
.panel-body.tight { padding: 0; }

/* ---------- 按钮 ---------- */
.btn {
  border: 1px solid var(--border); background: #fff; color: var(--text);
  padding: 7px 12px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px;
  transition: .12s; line-height: 1.2; white-space: nowrap;
}
.btn:hover { border-color: #cbd5e1; background: #f8fafc; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.danger { color: var(--red); border-color: #fecaca; background: #fff; }
.btn.danger:hover { background: var(--red-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--blue); }
.btn.ghost:hover { background: var(--blue-soft); }
.btn.sm { padding: 5px 9px; font-size: 12.5px; border-radius: 7px; }
.btn.xs { padding: 3px 7px; font-size: 12px; border-radius: 6px; }

/* ---------- 表单 ---------- */
.field { margin-bottom: 10px; }
.field > label { display: block; font-size: 12.5px; color: #374151; margin-bottom: 4px; font-weight: 500; }
.field .req { color: var(--red); }
.input, .select, .textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; outline: none; transition: .12s;
}
.input:focus, .select:focus, .textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.input[readonly] { background: #f9fafb; color: var(--muted); }
.textarea { min-height: 72px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px; }

/* ---------- 表格 ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 9px 10px; text-align: left; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.table th { background: #f8fafc; font-weight: 600; font-size: 12.5px; color: #374151; white-space: nowrap; }
.table tbody tr:hover { background: #f8fafc; }
.table td.actions { white-space: nowrap; }
.expand-row > td { background: #fbfcfe; padding: 0; }
.empty { padding: 26px; text-align: center; color: var(--muted); }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px;
  background: #f1f5f9; color: #475569; border: 1px solid transparent; white-space: nowrap;
}
.badge.blue { background: var(--blue-soft); color: var(--blue-dark); }
.badge.green { background: var(--green-soft); color: #15803d; }
.badge.orange { background: var(--orange-soft); color: #b45309; }
.badge.red { background: var(--red-soft); color: #b91c1c; }
.badge.purple { background: #f5f3ff; color: #6d28d9; }
.badge.gray { background: #f1f5f9; color: #64748b; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; }

/* ---------- 报告页卡 ---------- */
.page-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 12px; padding: 14px; }
.page-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #fff; }
.page-card .pc-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.page-card .pc-title { font-weight: 600; font-size: 13.5px; display: flex; align-items: center; gap: 6px; }
.page-card .pc-meta { color: var(--muted); font-size: 12px; margin: 4px 0 8px; }
.page-card .pc-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.file-list { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 8px; }
.file-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #475569; padding: 2px 0; }
.file-item .fname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- CRF 表单 ---------- */
.section { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 12px; background: #fff; overflow: hidden; }
.section-head { padding: 10px 14px; background: #f8fafc; display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.section-head h4 { font-size: 13.5px; }
.section-head .count { font-size: 12px; color: var(--muted); }
.section-body { padding: 6px 0 2px; }
.frow { display: grid; grid-template-columns: 220px 1fr; gap: 10px; padding: 7px 14px; border-top: 1px solid #f6f8fa; align-items: start; }
.frow:first-child { border-top: none; }
.frow.filled { background: #fcfdff; }
.frow .flabel { font-size: 13px; color: #374151; padding-top: 6px; }
.frow .flabel .unit { color: var(--muted); font-size: 12px; }
.frow .fvalue { min-width: 0; }
.frow .evidence { font-size: 11.5px; color: #94a3b8; margin-top: 4px; line-height: 1.5; word-break: break-all; }
.frow .evidence b { color: #64748b; font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; background: #fff; user-select: none; }
.chip.on { background: var(--blue-soft); border-color: #bfdbfe; color: var(--blue-dark); }
.issues { border-left: 3px solid var(--orange); background: var(--orange-soft); padding: 8px 12px; border-radius: 6px; margin-bottom: 6px; font-size: 12.5px; }
.issues.error { border-color: var(--red); background: var(--red-soft); }
.issues.info { border-color: var(--blue); background: var(--blue-soft); }

/* ---------- 评分 ---------- */
.score-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.score-card { border: 1px solid var(--border); border-radius: 10px; padding: 12px; background: #fff; }
.score-card .sc-name { font-size: 13px; font-weight: 600; }
.score-card .sc-value { font-size: 24px; font-weight: 700; color: var(--blue); line-height: 1.2; }
.score-card .sc-level { font-size: 12.5px; color: #334155; }
.score-card .sc-detail { font-size: 12px; color: var(--muted); margin-top: 6px; line-height: 1.5; }
.score-items { margin-top: 8px; border-top: 1px dashed var(--border); padding-top: 6px; }
.score-items .si { display: flex; justify-content: space-between; font-size: 12px; color: #475569; padding: 2px 0; }

/* ---------- 图表（纯 CSS 条形） ---------- */
.bars { display: flex; flex-direction: column; gap: 7px; }
.bar-item { font-size: 12.5px; }
.bar-label { display: flex; justify-content: space-between; color: #475569; margin-bottom: 3px; }
.bar-track { height: 8px; background: #eef2f7; border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, #3b82f6, #2563eb); border-radius: 999px; }

/* ---------- 弹窗 ---------- */
#modal-mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 100;
  display: flex; align-items: flex-start; justify-content: center; padding: 48px 16px; overflow: auto;
}
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 40px rgba(0,0,0,.2); }
.modal.wide { max-width: 900px; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 15px; }
.modal-body { padding: 16px 18px; max-height: 68vh; overflow: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ---------- 提示 ---------- */
#toasts { position: fixed; right: 18px; bottom: 18px; z-index: 200; display: flex; flex-direction: column; gap: 8px; }
.toast { background: #111827; color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow); max-width: 380px; }
.toast.ok { background: #065f46; }
.toast.err { background: #991b1b; }
.toast.warn { background: #92400e; }

/* ---------- 登录 ---------- */
#login {
  position: fixed; inset: 0; background: linear-gradient(135deg, #0f172a, #1e3a8a 60%, #2563eb);
  display: flex; align-items: center; justify-content: center; z-index: 300;
}
.login-card { background: #fff; border-radius: 14px; padding: 28px 26px; width: 360px; box-shadow: 0 24px 48px rgba(0,0,0,.3); }
.login-card h2 { font-size: 18px; margin-bottom: 4px; }

/* ---------- 打印 ---------- */
@media print {
  #sidebar, #topbar, .btn { display: none !important; }
  #content { padding: 0; }
}

/* ---------- 移动端适配（手机浏览器打开主应用时） ---------- */
@media (max-width: 820px) {
  #app { flex-direction: column; }
  #sidebar {
    width: 100%; flex: 0 0 auto; height: auto; position: static;
    display: flex; flex-direction: row; align-items: center; overflow-x: auto;
  }
  .brand { padding: 10px 12px; border-bottom: none; border-right: 1px solid #1e293b; flex: 0 0 auto; }
  .brand .t2 { display: none; }
  #nav { display: flex; padding: 6px; flex: 1; overflow-x: auto; }
  .nav-item { margin: 0 3px 0 0; padding: 8px 10px; white-space: nowrap; font-size: 13px; }
  .nav-item .ico { width: auto; }
  .sidebar-foot { display: none; }
  #topbar { height: auto; flex-wrap: wrap; padding: 8px 10px; gap: 6px; position: static; }
  #topbar .title { flex: 1 0 100%; font-size: 14px; }
  #content { padding: 10px; }
  .panel-head { flex-wrap: wrap; }
  .table th, .table td { padding: 7px 6px; font-size: 12.5px; }
  .table { display: block; overflow-x: auto; white-space: nowrap; }
  .frow { grid-template-columns: 1fr; gap: 2px; padding: 8px 10px; }
  .frow .flabel { padding-top: 0; }
  .page-grid { grid-template-columns: 1fr; }
  .score-grid { grid-template-columns: 1fr; }
  .modal { max-width: 100%; }
  #modal-mask { padding: 10px 8px; align-items: flex-start; }
  .modal-body { max-height: 72vh; }
  .btn { padding: 8px 10px; }
  .form-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 520px) {
  .form-grid { grid-template-columns: 1fr; }
}
