*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f5f6f8; color: #111827; font-size: 15px;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 100px;
}
#main { padding: 12px; min-height: 80vh; }
.loading { text-align: center; padding: 60px 0; color: #9ca3af; }
.empty { text-align: center; padding: 60px 0; color: #9ca3af; font-size: 14px; }
.empty small { display: block; margin-top: 6px; color: #c0c4cc; }
.empty-small { text-align: center; padding: 20px 0; color: #9ca3af; font-size: 13px; }

/* Card */
.card { background: #fff; border-radius: 14px; padding: 16px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,0.04); }

/* Search & Filter */
.search-box { margin-bottom: 12px; }
.search-box input { width: 100%; padding: 12px 16px; border: none; border-radius: 14px; font-size: 15px; background: #fff; outline: none; }
.filter-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.filter-tag { flex: 1; text-align: center; padding: 10px 0; border-radius: 10px; font-size: 13px; color: #6b7280; background: #fff; cursor: pointer; }
.filter-tag.active { background: #2563eb; color: #fff; }

/* Patient Card */
#patientList { position: relative; }
.patient-card { user-select: none; -webkit-user-select: none; }
.patient-card.dragging {
  opacity: 0.9;
  transform: scale(1.03);
  box-shadow: 0 10px 28px rgba(0,0,0,0.18);
  position: relative;
  z-index: 10;
  transition: none;
}
.pc-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
.pc-name { font-size: 18px; font-weight: 600; }
.pc-meta { font-size: 13px; color: #6b7280; }
.pc-tags { margin-bottom: 4px; }
.pc-followup { margin-top: 8px; font-size: 13px; font-weight: 500; }
.pc-followup.fu-pending { color: #9ca3af; }
.pc-followup.fu-overdue { color: #b91c1c; }
.pc-followup.fu-today { color: #c2410c; }
.pc-followup.fu-soon { color: #2563eb; }

/* Tags */
.tag { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; margin-right: 6px; }
.tag-blue { background: #dbeafe; color: #1d4ed8; }
.tag-green { background: #dcfce7; color: #166534; }
.tag-orange { background: #ffedd5; color: #c2410c; }
.tag-red { background: #fee2e2; color: #b91c1c; }
.tag-gray { background: #f1f3f5; color: #4b5563; }

/* Detail */
.detail-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.meta { display: block; font-size: 13px; color: #6b7280; margin-top: 4px; }
.edit-link { font-size: 13px; color: #2563eb; border: 1px solid #2563eb; padding: 4px 14px; border-radius: 20px; cursor: pointer; }
.notes-inline { font-size: 13px; color: #4b5563; background: #f8f9fb; padding: 12px; border-radius: 8px; margin-top: 8px; }

/* Followup Banner */
.followup-banner { background: linear-gradient(135deg, #2563eb, #1e40af); color: #fff; }
.fu-date { font-size: 22px; font-weight: 600; }
.fu-meta { font-size: 13px; opacity: 0.9; margin-top: 4px; }
.fu-meta b { font-weight: 600; }

/* Section Head */
.sec-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 15px; font-weight: 600; }
.add-link { font-size: 13px; color: #2563eb; cursor: pointer; }

/* List Item */
.list-item { display: flex; justify-content: space-between; align-items: center; padding: 14px 0; border-top: 1px solid #f1f3f5; cursor: pointer; }
.list-item:first-of-type { border-top: none; }
.li-title { font-size: 15px; font-weight: 500; display: block; }
.li-sub { font-size: 12px; color: #6b7280; margin-top: 3px; display: block; }
.arrow { font-size: 22px; color: #c0c4cc; }

/* Forms */
.section-title { font-size: 13px; color: #6b7280; margin: 18px 4px 8px; font-weight: 500; }
.form-block { background: #fff; border-radius: 14px; padding: 0 16px; margin-bottom: 4px; }
.frow { display: flex; align-items: center; padding: 14px 0; border-bottom: 1px solid #f1f3f5; }
.frow:last-child { border-bottom: none; }
.flabel { width: 100px; flex-shrink: 0; font-size: 14px; color: #6b7280; }
.frow input, .frow select, .frow textarea { flex: 1; border: none; outline: none; font-size: 14px; color: #111827; text-align: right; background: transparent; font-family: inherit; }
.frow textarea { text-align: left; resize: vertical; min-height: 48px; }

/* Switch */
.switch { position: relative; display: inline-block; }
.switch input { position: absolute; opacity: 0; }
.switch span { display: block; width: 48px; height: 26px; background: #d1d5db; border-radius: 13px; cursor: pointer; transition: .2s; }
.switch input:checked + span { background: #2563eb; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; border-radius: 50%; transition: .2s; }
.switch input:checked + span::after { left: 25px; }

/* Buttons */
.btn-primary { display: block; width: 100%; padding: 16px 0; background: #2563eb; color: #fff; border: none; border-radius: 12px; font-size: 16px; cursor: pointer; }
.btn-ghost { display: block; width: 100%; padding: 14px 0; background: #f1f5f9; color: #111827; border: none; border-radius: 12px; font-size: 15px; cursor: pointer; }
.btn-sm { padding: 8px 16px; font-size: 13px; background: #f1f5f9; border: none; border-radius: 8px; cursor: pointer; color: #2563eb; font-weight: 500; }

/* QR Code */
.qr-placeholder { display: flex; justify-content: center; padding: 12px 0; }
.qr-placeholder canvas, .qr-placeholder img { border-radius: 8px; }
.qr-clickable { cursor: pointer; -webkit-tap-highlight-color: transparent; }
.qr-clickable:active { opacity: 0.7; }
.qr-tip { text-align: center; font-size: 12px; color: #9ca3af; padding: 6px 0 12px; }
.qr-meta { text-align: center; font-size: 12px; color: #9ca3af; word-break: break-all; }

/* Suggestion */
.suggestion { background: #ecfdf5; border-left: 5px solid #10b981; margin-top: 12px; }
.sug-title { font-size: 13px; color: #065f46; }
.sug-date { font-size: 22px; font-weight: 600; color: #064e3b; margin: 4px 0; }
.sug-note { font-size: 13px; color: #047857; }
.checkbox-label { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 13px; color: #064e3b; }

/* Stats */
.stats-bar { display: flex; background: #fff; border-radius: 14px; padding: 20px 0; margin-bottom: 14px; }
.stat { flex: 1; text-align: center; border-right: 1px solid #f1f3f5; font-size: 12px; color: #6b7280; }
.stat:last-child { border-right: none; }
.stat-num { display: block; font-size: 24px; font-weight: 600; color: #2563eb; }

/* Followup Cards */
.group { margin-bottom: 16px; }
.group-title { font-size: 13px; color: #6b7280; margin: 0 4px 10px; font-weight: 500; }
.fu-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.fu-name { font-size: 16px; font-weight: 600; }
.fu-date-c { font-size: 13px; font-weight: 500; color: #2563eb; }
.fu-date-c.overdue { color: #b91c1c; }
.fu-date-c.today { color: #c2410c; }
.fu-note { font-size: 13px; color: #4b5563; margin-bottom: 10px; }
.fu-actions { display: flex; border-top: 1px solid #f1f3f5; padding-top: 10px; }
.act-btn { flex: 1; text-align: center; font-size: 13px; color: #2563eb; background: none; border: none; cursor: pointer; padding: 6px 0; }

/* Images */
.img-grid { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px 0; }
.img-wrap { position: relative; width: 80px; height: 80px; }
.img-wrap img { width: 100%; height: 100%; object-fit: cover; border-radius: 8px; }
.img-del { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; background: #ef4444; color: #fff; text-align: center; line-height: 20px; font-size: 16px; cursor: pointer; }

/* TabBar */
#tabBar { position: fixed; bottom: 0; left: 0; right: 0; display: flex; background: #fff; border-top: 1px solid #eee; padding: 8px 0 env(safe-area-inset-bottom, 8px) 0; z-index: 100; }
.tab-item { flex: 1; text-align: center; font-size: 12px; color: #9aa0a6; cursor: pointer; padding: 6px 0; }
.tab-item.active { color: #2563eb; font-weight: 500; }
.tab-icon { font-size: 22px; display: block; margin-bottom: 2px; }
.spacer { height: 20px; }

/* FAB */
.fab {
  position: fixed;
  bottom: 110px;
  right: 20px;
  width: 56px;
  height: 56px;
  background: #2563eb;
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  box-shadow: 0 4px 16px rgba(37,99,235,0.45);
  z-index: 200;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
