/* ===== 筛选栏 ===== */
.filter-bar {
  background: var(--paper-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: flex-end;
  box-shadow: var(--shadow);
}
.filter-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.filter-item label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}
.filter-item select {
  padding: 7px 32px 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  min-width: 130px;
  appearance: none;
  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='%238a8a8a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px;
}
.filter-item input[type="date"] {
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  min-width: 140px;
}
.filter-item select:focus,
.filter-item input[type="date"]:focus { border-color: var(--ink); }
.filter-item input[type="date"] { min-width: 140px; }
.filter-actions {
  margin-left: auto;
  display: flex;
  gap: 16px;
  align-items: center;
  padding-left: 16px;
  border-left: 1px solid var(--border-soft);
}
.filter-actions .btn {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--text-soft);
  transition: all 0.2s;
}
.filter-actions .btn:hover {
  border-color: var(--ink);
  color: var(--ink);
  background: rgba(26, 77, 74, 0.05);
}
.filter-result {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 0;
}
.filter-result b {
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
}

/* ===== 表格 ===== */
.records-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--paper-card);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.records-cards { display: none; }
.records-table thead {
  background: var(--ink);
}
.records-table thead th {
  color: #fff;
  font-weight: 500;
  font-size: 13px;
  padding: 14px 16px;
  text-align: left;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.records-table tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}
.records-table tbody tr:nth-child(even) { background: rgba(245, 241, 232, 0.4); }
.records-table tbody tr { transition: background 0.15s; cursor: pointer; }
.records-table tbody tr:hover { background: rgba(184, 145, 70, 0.08); }
.records-table tbody tr:last-child td { border-bottom: none; }
.rec-date { color: var(--text-soft); font-variant-numeric: tabular-nums; white-space: nowrap; }
.rec-patient { font-weight: 500; color: var(--ink); }
.rec-title { font-weight: 500; }
.rec-dept {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(26, 77, 74, 0.08);
  color: var(--ink);
  border-radius: 4px;
  font-size: 12px;
}
.rec-attach {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--gold);
}
.rec-attach.empty { color: var(--text-muted); opacity: 0.4; }

/* ===== 分页 ===== */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 24px;
}
.page-btn {
  min-width: 36px;
  height: 36px;
  border-radius: var(--r);
  border: 1px solid var(--border);
  background: var(--paper-card);
  color: var(--text-soft);
  font-size: 14px;
  transition: all 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: var(--ink); color: var(--ink); }
.page-btn.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-info { font-size: 13px; color: var(--text-muted); margin: 0 12px; }

/* ===== 详情弹窗 ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 56, 54, 0.55);
  backdrop-filter: blur(4px);
  z-index: 300;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-overlay.show { display: flex; animation: fadeIn 0.25s ease; }
.modal {
  background: var(--paper-card);
  border-radius: var(--r-lg);
  width: 100%;
  max-width: 920px;
  max-height: 88vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gold);
  animation: modalIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
@keyframes modalIn { from { opacity: 0; transform: scale(0.96) translateY(20px); } to { opacity: 1; transform: scale(1) translateY(0); } }
.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 28px 18px;
  border-bottom: 1px solid var(--border-soft);
  background: linear-gradient(135deg, var(--paper-card), var(--paper-dark));
}
.modal-head h2 { font-family: var(--font-serif); font-size: 22px; color: var(--ink); margin-bottom: 6px; }
.modal-head .meta { font-size: 13px; color: var(--text-muted); display: flex; gap: 16px; flex-wrap: wrap; }
.modal-head .meta span b { color: var(--text-soft); font-weight: 500; }
.modal-close {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  color: var(--text-muted);
  font-size: 22px;
  transition: all 0.2s;
  flex-shrink: 0;
}
.modal-close:hover { background: var(--red); color: #fff; }
.modal-body { padding: 24px 28px; overflow-y: auto; overflow-x: hidden; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}
.detail-section h3 {
  font-family: var(--font-serif);
  font-size: 16px;
  color: var(--ink);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gold);
  display: inline-block;
}
.field-list { display: flex; flex-direction: column; gap: 10px; }
.field-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  font-size: 14px;
}
.field-item .flabel { color: var(--text-muted); }
.field-item .fvalue { color: var(--text); }
.field-item.custom .flabel { color: var(--gold); font-weight: 500; }
.field-item.custom .fvalue { font-family: var(--font-serif); font-weight: 600; color: var(--ink); }

.attach-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.attach-thumb {
  aspect-ratio: 1;
  border-radius: var(--r);
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  position: relative;
  background: var(--paper-dark);
  transition: all 0.2s;
}
.attach-thumb:hover { border-color: var(--gold); transform: scale(1.03); box-shadow: var(--shadow); }
.attach-thumb img { width: 100%; height: 100%; object-fit: cover; }
.attach-thumb .aname {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.7));
  color: #fff;
  font-size: 11px;
  padding: 12px 8px 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.attach-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 24px;
  color: var(--text-muted);
  font-size: 13px;
  border: 1px dashed var(--border);
  border-radius: var(--r);
}

/* 上传区 */
.upload-area {
  margin-top: 16px;
  padding: 18px;
  border: 2px dashed var(--border);
  border-radius: var(--r);
  background: linear-gradient(135deg, var(--paper), var(--paper-card));
  text-align: center;
  transition: all 0.25s;
  position: relative;
}
.upload-area:hover { border-color: var(--gold); background: linear-gradient(135deg, var(--paper-card), var(--paper)); }
.upload-area.dragover { border-color: var(--gold); background: rgba(184,145,70,0.08); }
.upload-icon {
  font-size: 28px;
  margin-bottom: 8px;
  opacity: 0.6;
}
.upload-title {
  font-size: 14px;
  color: var(--text);
  margin-bottom: 4px;
  font-weight: 500;
}
.upload-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}
.upload-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}
.upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 20px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--r);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  border: none;
}
.upload-btn:hover { background: var(--ink-dark); transform: translateY(-1px); box-shadow: var(--shadow); }
.upload-btn.secondary {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
}
.upload-btn.secondary:hover { border-color: var(--ink); background: var(--paper-dark); }
.upload-size-select {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-soft);
}
.upload-size-select select {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--paper-card);
  color: var(--text);
  outline: none;
}
.upload-progress {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.upload-progress.error { color: var(--red); }
.upload-progress.success { color: var(--green); }

/* 新增病历弹窗表单 */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 16px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-field.full { grid-column: 1 / -1; }
.form-field label {
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
}
.form-field label .req { color: var(--red); margin-left: 2px; }
.form-field input,
.form-field select,
.form-field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r);
  background: var(--paper);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus { border-color: var(--ink); }
.form-field textarea { min-height: 70px; }
.custom-fields-editor {
  margin-top: 14px;
  padding: 14px;
  background: var(--paper);
  border-radius: var(--r);
  border: 1px dashed var(--border);
}
.custom-fields-editor h4 {
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.custom-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr 36px;
  gap: 8px;
  margin-bottom: 8px;
}
.custom-field-row input {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--paper-card);
  font-size: 13px;
}
.custom-field-row .del-btn {
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--r-sm);
  font-size: 18px;
  transition: all 0.2s;
}
.custom-field-row .del-btn:hover { background: var(--red); color: #fff; }
.add-field-btn {
  margin-top: 4px;
  padding: 6px 14px;
  border: 1px dashed var(--border);
  border-radius: var(--r-sm);
  color: var(--text-soft);
  font-size: 13px;
  cursor: pointer;
  background: transparent;
  transition: all 0.2s;
  width: 100%;
}
.add-field-btn:hover { border-color: var(--gold); color: var(--gold); }
.modal-foot {
  padding: 16px 28px;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--paper);
}

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.4; }
.empty-state p { font-size: 14px; }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
  .filter-bar { gap: 10px; padding: 14px; }
  .filter-item { flex: 1 1 calc(50% - 10px); min-width: 0; }
  .filter-item select,
  .filter-item input[type="date"] { min-width: 0; width: 100%; }
  .filter-actions { margin-left: 0; width: 100%; justify-content: space-between; }
  .records-table { display: none; }
  .records-cards { display: block; }
  .record-card {
    background: var(--paper-card);
    border-radius: var(--r);
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: var(--shadow);
    border-left: 3px solid var(--gold);
    cursor: pointer;
    transition: all 0.15s;
  }
  .record-card:hover { transform: translateX(4px); }
  .record-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
  }
  .record-card-title { font-weight: 600; color: var(--ink); font-size: 15px; line-height: 1.4; }
  .record-card-date { font-size: 12px; color: var(--text-muted); white-space: nowrap; }
  .record-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 12px;
  }
  .record-card-meta span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    color: var(--text-soft);
  }
  .record-card-meta .tag {
    padding: 2px 6px;
    background: rgba(26,77,74,0.08);
    border-radius: 3px;
    color: var(--ink);
  }
  .modal-overlay { padding: 0; }
  .modal {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 16px 16px 0 0;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    overflow-x: hidden;
  }
  .modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; overflow-x: hidden; }
  .modal-head { padding: 18px 20px 14px; }
  .modal-foot { padding: 12px 20px; }
  .form-grid { grid-template-columns: 1fr; gap: 12px; }
  .upload-area { padding: 14px; }
  .upload-buttons { flex-direction: column; align-items: stretch; }
  .upload-btn { justify-content: center; }
  /* 移动端自定义字段适配 */
  .custom-fields-editor { box-sizing: border-box; }
  .custom-field-row {
    grid-template-columns: 1fr 1fr 30px;
    gap: 6px;
    min-width: 0;
    box-sizing: border-box;
  }
  .custom-field-row input {
    padding: 6px 8px;
    font-size: 12px;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
  }
  .custom-field-row .del-btn {
    font-size: 14px;
    min-width: 0;
    width: 30px;
    height: 30px;
    padding: 0;
    box-sizing: border-box;
  }
  /* 移动端详情弹窗：单栏布局，图片附件放最下方 */
  .detail-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
  .detail-grid .detail-section:last-child {
    order: 2;
  }
}
