/* ==========================================================================
   患者资料管理 · 手机端样式
   移动优先，兼容 Android 8.1 WebView（Chromium 67）：不使用 flex gap、
   aspect-ratio、backdrop-filter、dvh 等新特性；env() 均带降级声明。
   ========================================================================== */

:root {
  --blue: #0f63c8;
  --blue-2: #1283cc;
  --blue-deep: #0b4fa8;
  --teal: #0d9b8f;
  --teal-deep: #0b7f76;
  --ink: #16263a;
  --text: #23364e;
  --muted: #66788d;
  --muted-2: #8a9aad;
  --bg: #eef3f8;
  --card: #ffffff;
  --line: #e3eaf2;
  --line-soft: #f0f4f9;
  --danger: #c93030;
  --amber-bg: #fff7e6;
  --amber-line: #f6e0b5;
  --amber-text: #94590a;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(15, 42, 78, 0.05), 0 8px 22px -14px rgba(15, 42, 78, 0.28);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body.modal-open,
body.no-scroll {
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

a {
  color: var(--blue);
}

h1, h2, h3, p {
  margin: 0;
}

svg {
  display: block;
}

.muted {
  color: var(--muted);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  position: relative;
}

.has-tabbar {
  padding-bottom: 72px;
  padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

/* ---------------- 通用按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 46px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 12px;
  background: #f1f5fa;
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  line-height: 1;
  text-decoration: none;
  cursor: pointer;
  outline: none;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
  -webkit-user-select: none;
  user-select: none;
}

.btn:active {
  transform: scale(0.975);
  filter: brightness(0.97);
}

.btn:disabled,
.btn.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-2) 100%);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(15, 99, 200, 0.9);
}

.btn-outline {
  background: #fff;
  border-color: #cfdff0;
  color: #1d5f9e;
}

.btn-ghost {
  background: #eef3f9;
  color: #42536a;
}

.btn-danger {
  background: linear-gradient(135deg, #cf2f2f 0%, #de4a38 100%);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(200, 40, 40, 0.8);
}

.btn-danger-ghost {
  background: #fff;
  border-color: #f0c7c7;
  color: #bd2f2f;
}

.btn-teal {
  background: linear-gradient(135deg, #0b8f86 0%, #10b3a4 100%);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(11, 143, 134, 0.85);
}

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg {
  height: 50px;
  font-size: 17px;
  border-radius: 13px;
}

.btn-sm {
  height: 34px;
  padding: 0 12px;
  font-size: 13.5px;
  border-radius: 9px;
  font-weight: 600;
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #eff3f8;
  color: #5b6d82;
  cursor: pointer;
  flex: none;
}

.icon-btn svg {
  width: 17px;
  height: 17px;
}

.head-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  flex: none;
}

.head-icon-btn svg {
  width: 22px;
  height: 22px;
}

.head-icon-btn:active {
  background: rgba(255, 255, 255, 0.28);
}

.link-btn {
  display: inline-block;
  padding: 2px 4px;
  border: none;
  background: none;
  color: var(--blue);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.link-danger {
  color: var(--danger);
}

/* ---------------- 加载 / 提示 ---------------- */

.spinner {
  display: inline-block;
  width: 26px;
  height: 26px;
  border: 3px solid rgba(255, 255, 255, 0.28);
  border-top-color: #fff;
  border-radius: 50%;
  animation: pr-spin 0.8s linear infinite;
}

.spinner-dark {
  width: 20px;
  height: 20px;
  border-color: rgba(15, 99, 200, 0.18);
  border-top-color: var(--blue);
}

@keyframes pr-spin {
  to { transform: rotate(360deg); }
}

.inline-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 46px 16px;
  color: var(--muted);
  font-size: 14px;
}

.inline-loading .spinner {
  margin-right: 10px;
}

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 70vh;
}

.loading-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 250;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(238, 243, 248, 0.72);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.loading-overlay.show {
  opacity: 1;
}

.loading-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 28px;
  border-radius: 16px;
  background: rgba(20, 36, 56, 0.92);
  color: #fff;
  box-shadow: 0 18px 40px -18px rgba(4, 24, 48, 0.7);
}

.loading-box .loading-text {
  margin-top: 12px;
  font-size: 13.5px;
  max-width: 220px;
  text-align: center;
  line-height: 1.5;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  bottom: calc(96px + env(safe-area-inset-bottom, 0px));
  z-index: 300;
  max-width: 86%;
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(22, 38, 58, 0.94);
  color: #fff;
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  box-shadow: 0 12px 28px -14px rgba(4, 20, 40, 0.8);
  opacity: 0;
  transform: translate(-50%, 8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast-error {
  background: rgba(176, 40, 40, 0.96);
}

.toast-success {
  background: rgba(9, 122, 112, 0.96);
}

.offline-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  background: #fff3d6;
  border-bottom: 1px solid #f2dfb0;
  color: #8a5305;
  font-size: 12.5px;
  line-height: 1.4;
}

.offline-dot {
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 50%;
  background: #d9820b;
  flex: none;
}

.noscript {
  padding: 40px 20px;
  text-align: center;
  color: var(--muted);
}

/* ---------------- 空状态 ---------------- */

.empty-state {
  padding: 48px 24px 56px;
  text-align: center;
}

.empty-icon {
  color: #b9c8d8;
  margin: 0 auto;
}

.empty-icon svg {
  width: 72px;
  height: 72px;
  margin: 0 auto;
}

.empty-title {
  margin-top: 14px;
  font-size: 16px;
  font-weight: 600;
  color: #41536a;
}

.empty-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.empty-state .btn {
  margin-top: 18px;
}

/* ---------------- 表单控件 ---------------- */

.form-group {
  margin-bottom: 14px;
  min-width: 0;
}

.form-label {
  display: block;
  margin-bottom: 7px;
  color: #34455c;
  font-size: 14px;
  font-weight: 600;
}

.form-label .req {
  margin-left: 2px;
  color: var(--danger);
}

.form-input {
  display: block;
  width: 100%;
  height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafd;
  color: var(--ink);
  font-size: 16px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.form-input:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(15, 99, 200, 0.12);
}

.form-textarea {
  height: auto;
  min-height: 96px;
  padding: 11px 12px;
  line-height: 1.6;
  resize: vertical;
}

.form-select {
  padding-right: 30px;
}

.form-hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.form-hint-block {
  margin: -6px 0 14px;
}

.form-grid {
  display: flex;
  flex-wrap: wrap;
}

.form-grid .form-group {
  flex: 1 1 0;
  min-width: 0;
}

.form-grid .form-group + .form-group {
  margin-left: 10px;
}

/* 性别分段选择 */
.seg {
  display: flex;
  padding: 3px;
  border-radius: 11px;
  background: #f1f5fa;
}

.seg-item {
  position: relative;
  flex: 1;
  min-width: 0;
}

.seg-item input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.seg-item span {
  display: block;
  padding: 9px 0;
  border-radius: 8px;
  color: var(--muted);
  font-size: 15px;
  text-align: center;
  transition: background 0.15s ease, color 0.15s ease;
}

.seg-item input:checked + span {
  background: #fff;
  color: var(--blue);
  font-weight: 600;
  box-shadow: 0 1px 4px rgba(15, 42, 78, 0.14);
}

/* ---------------- 登录页 ---------------- */

.app-login {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  min-height: 100vh;
  padding: 44px 22px 28px;
  padding-top: 44px;
  padding-top: calc(44px + env(safe-area-inset-top, 0px));
  padding-bottom: 28px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(160deg, #0a4a9e 0%, #0f6ec2 46%, #0d9b98 100%);
}

.login-hero {
  text-align: center;
  color: #fff;
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 82px;
  height: 82px;
  margin: 4px auto 16px;
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.18);
}

.login-logo svg {
  width: 54px;
  height: 54px;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 2px;
}

.login-sub {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 13px;
  letter-spacing: 0.5px;
}

.login-card {
  margin-top: 30px;
  padding: 22px 18px 18px;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 22px 46px -20px rgba(4, 32, 70, 0.55);
}

.login-card .form-group:last-of-type {
  margin-bottom: 10px;
}

.login-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border: 1px solid #f5c8c8;
  border-radius: 10px;
  background: #fdeeee;
  color: #b42318;
  font-size: 13px;
  line-height: 1.55;
}

.login-note {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.login-footer {
  margin-top: auto;
  padding-top: 26px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.4px;
}

/* ---------------- 列表页 ---------------- */

.app-head {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 12px 16px 24px;
  padding-top: 12px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  border-radius: 0 0 22px 22px;
  background: linear-gradient(135deg, #0b4fa8 0%, #0f6ec2 52%, #0e8fc4 100%);
  color: #fff;
  box-shadow: 0 10px 24px -18px rgba(8, 45, 96, 0.7);
}

.app-head-simple {
  padding-bottom: 18px;
  border-radius: 0 0 18px 18px;
}

.head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.head-titles {
  min-width: 0;
}

.head-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.head-sub {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.84);
  font-size: 12.5px;
}

.search-box {
  display: flex;
  align-items: center;
  height: 44px;
  margin-top: 14px;
  padding: 0 10px;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 6px 16px -12px rgba(6, 34, 70, 0.6);
}

.search-icon {
  flex: none;
  color: #7b8ea4;
}

.search-icon svg {
  width: 20px;
  height: 20px;
}

.search-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 8px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-size: 15px;
  outline: none;
  -webkit-appearance: none;
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-input::-webkit-input-placeholder {
  color: #93a5ba;
}

.search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #e8eef6;
  color: #5c6f85;
  flex: none;
}

.search-clear svg {
  width: 13px;
  height: 13px;
}

.stats-row {
  position: relative;
  z-index: 2;
  display: flex;
  margin: 8px 14px 0;
}

.stat-card {
  flex: 1;
  min-width: 0;
  padding: 12px 6px 10px;
  border-radius: 14px;
  background: #fff;
  box-shadow: var(--shadow);
  text-align: center;
}

.stat-card + .stat-card {
  margin-left: 8px;
}

.stat-value {
  font-size: 21px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: 0.5px;
}

.stat-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.stat-blue .stat-value { color: var(--blue); }
.stat-teal .stat-value { color: var(--teal); }
.stat-slate .stat-value { color: #445a74; }

.cache-note {
  margin: 10px 14px 0;
  padding: 8px 11px;
  border: 1px solid var(--amber-line);
  border-radius: 10px;
  background: var(--amber-bg);
  color: var(--amber-text);
  font-size: 12px;
  line-height: 1.55;
}

.detail-head + .cache-note {
  margin-top: 10px;
}

.list-body {
  padding: 14px 14px 26px;
}

.patient-card {
  display: flex;
  align-items: stretch;
  margin-bottom: 10px;
  padding: 13px 12px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
  color: inherit;
  text-decoration: none;
  transition: transform 0.12s ease;
}

.patient-card:active {
  transform: scale(0.985);
}

.bed-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 52px;
  min-height: 58px;
  padding: 6px 2px;
  border-radius: 13px;
  background: linear-gradient(160deg, #eaf3ff 0%, #dcecff 100%);
  color: var(--blue);
  flex: none;
  align-self: flex-start;
}

.bed-badge .bed-no {
  max-width: 100%;
  overflow: hidden;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: -0.5px;
}

.bed-badge .bed-label {
  margin-top: 1px;
  color: #5f82ad;
  font-size: 10px;
  letter-spacing: 0.5px;
}

.bed-badge.bed-empty {
  background: #f1f5fa;
  color: #9aabbf;
}

.bed-badge.bed-empty .bed-label {
  color: #9aabbf;
}

.bed-history {
  background: linear-gradient(160deg, #e9f7f5 0%, #dcf2ef 100%);
  color: var(--teal-deep);
}

.bed-history .bed-icon svg {
  width: 21px;
  height: 21px;
}

.bed-history .bed-label {
  color: #4d8d86;
}

.pc-main {
  flex: 1;
  min-width: 0;
  margin-left: 12px;
}

.pc-title {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
}

.pc-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.35;
}

.pc-meta {
  margin-left: 8px;
  color: var(--muted);
  font-size: 13px;
}

.pc-diag {
  margin-top: 3px;
  overflow: hidden;
  color: #3b4e66;
  font-size: 14px;
  line-height: 1.45;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pc-tags {
  display: flex;
  flex-wrap: wrap;
  margin-top: 7px;
}

.pc-tag {
  margin: 0 6px 3px 0;
  padding: 1px 7px;
  border-radius: 6px;
  background: #f4f7fb;
  color: var(--muted);
  font-size: 11.5px;
  line-height: 1.7;
}

.pc-tag-stay {
  background: #eaf3ff;
  color: #2464ad;
}

.pc-tag-discharge {
  background: #e6f5f3;
  color: var(--teal-deep);
  font-weight: 600;
}

.pc-thumb {
  position: relative;
  width: 58px;
  height: 58px;
  margin-left: 10px;
  border-radius: 11px;
  background: #eef3f9;
  overflow: hidden;
  flex: none;
  align-self: flex-start;
}

.pc-thumb img {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.pc-thumb img.is-loaded {
  opacity: 1;
}

.pc-thumb.has-photo .pc-thumb-ph {
  display: none;
}

.pc-thumb-ph {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #b3c3d5;
  transform: translate(-50%, -50%);
}

.pc-thumb-ph svg {
  width: 24px;
  height: 24px;
}

.pc-thumb-empty .pc-thumb-ph {
  position: static;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  transform: none;
}

.pc-photo-count {
  position: absolute;
  right: 3px;
  bottom: 3px;
  z-index: 2;
  padding: 0 5px;
  border-radius: 8px;
  background: rgba(12, 32, 58, 0.68);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
}

.load-more {
  margin-top: 6px;
}

.fab {
  position: fixed;
  right: 16px;
  bottom: 76px;
  bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  z-index: 35;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 19px;
  background: linear-gradient(135deg, #0f63c8 0%, #138fd0 100%);
  color: #fff;
  box-shadow: 0 14px 26px -10px rgba(15, 99, 200, 0.85);
  text-decoration: none;
  transition: transform 0.12s ease;
}

.fab:active {
  transform: scale(0.94);
}

.fab svg {
  width: 27px;
  height: 27px;
}

/* ---------------- 底部 Tab ---------------- */

.tabbar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 40;
  display: flex;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 0;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 -8px 24px -20px rgba(15, 42, 78, 0.6);
}

.tab-item {
  display: flex;
  flex: 1;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 57px;
  color: var(--muted-2);
  font-size: 11.5px;
  text-decoration: none;
  transition: color 0.15s ease;
}

.tab-item svg {
  width: 23px;
  height: 23px;
  margin-bottom: 2px;
}

.tab-item.is-active {
  color: var(--blue);
  font-weight: 600;
}

.tab-item.is-active svg {
  stroke-width: 2.1;
}

/* ---------------- 详情页 ---------------- */

.detail-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  padding: 10px 12px 15px;
  padding-top: 10px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, #0b4fa8 0%, #0f6ec2 55%, #0e8fc4 100%);
  color: #fff;
  box-shadow: 0 10px 24px -18px rgba(8, 45, 96, 0.7);
}

.detail-head-main {
  flex: 1;
  min-width: 0;
  margin: 0 10px;
}

.detail-name-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}

.detail-name {
  overflow: hidden;
  max-width: 100%;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status-pill {
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.6;
  flex: none;
}

.status-in {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

.status-out {
  background: rgba(9, 122, 112, 0.85);
  color: #eafffd;
}

.detail-sub {
  margin-top: 4px;
  overflow: hidden;
  color: rgba(255, 255, 255, 0.84);
  font-size: 12.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.head-spacer {
  width: 40px;
  height: 40px;
  flex: none;
}

.detail-body {
  padding: 14px 14px 26px;
}

.section {
  margin-bottom: 12px;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.section-title {
  display: flex;
  align-items: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.count-badge {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 8px;
  border-radius: 999px;
  background: #eaf3ff;
  color: var(--blue);
  font-size: 12px;
  font-weight: 600;
}

.detail-head .head-icon-btn + .detail-head-main + .head-icon-btn {
  margin-left: 0;
}

/* 照片墙 */
.photo-wall {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-gap: 8px;
  gap: 8px;
}

.photo-cell {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  padding-top: 100%;
  border: none;
  border-radius: 11px;
  background: #eef3f9;
  overflow: hidden;
  cursor: pointer;
}

.photo-cell img {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.photo-cell img.is-loaded {
  opacity: 1;
}

.photo-cell.has-photo .photo-cell-ph {
  display: none;
}

.photo-cell-ph {
  position: absolute;
  top: 50%;
  left: 50%;
  color: #b3c3d5;
  transform: translate(-50%, -50%);
}

.photo-cell-ph svg {
  width: 26px;
  height: 26px;
}

.photo-empty {
  padding: 24px 16px;
  border: 1px dashed #cfdceb;
  border-radius: 12px;
  background: #fafcff;
  color: var(--muted);
  text-align: center;
}

.photo-empty-icon {
  display: inline-flex;
  color: #b3c3d5;
}

.photo-empty-icon svg {
  width: 42px;
  height: 42px;
}

.photo-empty p {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.65;
}

.photo-buttons {
  display: flex;
  margin-top: 12px;
}

.photo-btn {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  height: 46px;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease;
}

.photo-btn:active {
  transform: scale(0.975);
}

.photo-btn svg {
  width: 21px;
  height: 21px;
  margin-right: 7px;
}

.photo-btn-primary {
  background: linear-gradient(135deg, #0f63c8 0%, #1786d4 100%);
  color: #fff;
  box-shadow: 0 8px 18px -10px rgba(15, 99, 200, 0.9);
}

.photo-btn-secondary {
  margin-left: 10px;
  background: #e9f6f5;
  border: 1px solid #cce9e6;
  color: var(--teal-deep);
}

/* 基本信息 */
.info-list {
  padding: 0;
}

.info-row {
  display: flex;
  align-items: flex-start;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}

.info-row:last-child {
  border-bottom: none;
  padding-bottom: 2px;
}

.info-label {
  width: 82px;
  flex: none;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}

.info-value {
  flex: 1;
  min-width: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
}

.info-row-block {
  display: block;
}

.info-row-block .info-label {
  width: auto;
  margin-bottom: 3px;
}

.info-row-block .info-value {
  display: block;
  line-height: 1.65;
}

.phone-link {
  color: var(--blue);
  text-decoration: none;
}

/* 备注时间线 */
.note-timeline {
  position: relative;
}

.note-item {
  position: relative;
  padding-left: 20px;
  padding-bottom: 16px;
}

.note-item::before {
  content: "";
  position: absolute;
  top: 17px;
  bottom: 0;
  left: 3px;
  width: 2px;
  background: #e6eef7;
}

.note-item:last-child {
  padding-bottom: 2px;
}

.note-item:last-child::before {
  display: none;
}

.note-dot {
  position: absolute;
  top: 6px;
  left: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 0 3px #e8f6f4;
}

.note-text {
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.note-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 6px;
}

.note-time {
  color: var(--muted-2);
  font-size: 12px;
}

.note-actions {
  margin-left: 8px;
  flex: none;
}

.note-actions .link-btn + .link-btn {
  margin-left: 4px;
}

.note-empty {
  padding: 6px 0 2px;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.7;
}

/* 详情操作 */
.detail-actions {
  padding-top: 2px;
}

.detail-actions .btn {
  margin-bottom: 10px;
}

.detail-actions .btn:last-child {
  margin-bottom: 0;
}

.app-detail .head-icon-btn {
  flex: none;
}

.app-detail .detail-head .head-icon-btn:last-child {
  margin-left: 0;
}

/* ---------------- 全屏照片查看 ---------------- */

.viewer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  background: #05080d;
  color: #fff;
}

.viewer-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  padding-top: 10px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  flex: none;
}

.viewer-count {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  letter-spacing: 0.5px;
}

.viewer-icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
  cursor: pointer;
}

.viewer-icon-btn svg {
  width: 20px;
  height: 20px;
}

.viewer-stage {
  position: relative;
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  min-height: 0;
  overflow: hidden;
}

.viewer-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: pan-y;
}

.viewer-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.viewer-img.is-loaded {
  opacity: 1;
}

.viewer-status {
  position: absolute;
  top: 50%;
  left: 50%;
  max-width: 82%;
  color: rgba(255, 255, 255, 0.75);
  font-size: 13px;
  text-align: center;
  transform: translate(-50%, -50%);
}

.viewer-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 56px;
  margin-top: -28px;
  padding: 0;
  border: none;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: pointer;
}

.viewer-nav svg {
  width: 24px;
  height: 24px;
}

.viewer-nav:disabled {
  opacity: 0.22;
  pointer-events: none;
}

.viewer-nav-prev {
  left: 8px;
}

.viewer-nav-next {
  right: 8px;
}

.viewer-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  padding-bottom: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  flex: none;
}

.viewer-date {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12.5px;
}

.viewer-delete {
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  border: 1px solid rgba(255, 120, 120, 0.4);
  border-radius: 12px;
  background: rgba(200, 44, 44, 0.22);
  color: #ffb4b4;
  font-size: 14px;
  cursor: pointer;
}

.viewer-delete svg {
  width: 18px;
  height: 18px;
  margin-right: 6px;
}

/* ---------------- 新建 / 编辑表单 ---------------- */

.form-head {
  display: flex;
  align-items: center;
  padding: 10px 12px 15px;
  padding-top: 10px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: linear-gradient(135deg, #0b4fa8 0%, #0f6ec2 55%, #0e8fc4 100%);
  color: #fff;
  box-shadow: 0 10px 24px -18px rgba(8, 45, 96, 0.7);
}

.form-head .head-icon-btn {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.form-head-main {
  flex: 1;
  min-width: 0;
  margin-left: 10px;
}

.form-title {
  font-size: 19px;
  font-weight: 700;
}

.form-sub {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 12px;
}

.form-body {
  padding: 14px 14px 0;
}

.form-card {
  padding: 16px 14px 2px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.form-actions {
  padding: 12px 14px 16px;
  padding-bottom: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
}

.form-actions .btn + .btn {
  margin-top: 10px;
}

/* ---------------- 设置页 ---------------- */

.settings-body {
  padding: 14px;
}

.settings-card {
  margin-bottom: 12px;
  padding: 16px 14px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.settings-title {
  margin-bottom: 4px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 700;
}

.setting-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}

.setting-row:last-of-type {
  border-bottom: none;
}

.setting-label {
  margin-right: 12px;
  color: var(--muted);
  font-size: 14px;
  flex: none;
}

.setting-value {
  min-width: 0;
  color: var(--ink);
  font-size: 13.5px;
  font-weight: 600;
  text-align: right;
  word-break: break-all;
}

.setting-value-wrap {
  font-weight: 500;
  font-size: 13px;
  color: #42536a;
}

.setting-hint {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.settings-desc {
  margin: 8px 0 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.75;
}

.settings-card .btn {
  margin-top: 12px;
}

.version-line {
  margin-top: 14px;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
}

.version-sub {
  margin-top: 4px;
  color: #adb9c9;
}

/* ---------------- 弹窗 ---------------- */

.modal-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 150;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(9, 20, 36, 0.5);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.modal-overlay.show {
  opacity: 1;
}

.modal-panel {
  width: 100%;
  max-width: 480px;
  max-height: 92vh;
  border-radius: 20px 20px 0 0;
  background: #fff;
  box-shadow: 0 -16px 40px -20px rgba(4, 20, 44, 0.6);
  transform: translateY(24px);
  transition: transform 0.22s ease;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modal-overlay.show .modal-panel {
  transform: translateY(0);
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 8px;
  flex: none;
}

.modal-title {
  color: var(--ink);
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 4px 18px 10px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-foot {
  display: flex;
  padding: 10px 18px;
  padding-bottom: 10px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  flex: none;
}

.modal-foot .btn {
  flex: 1;
}

.modal-foot .btn + .btn {
  margin-left: 10px;
}

.modal-error {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid #f5c8c8;
  border-radius: 8px;
  background: #fdeeee;
  color: #b42318;
  font-size: 12.5px;
  line-height: 1.5;
}

.modal-error:empty {
  display: none;
}

.dialog-text {
  color: #2b3e56;
  font-size: 15px;
  line-height: 1.65;
  padding: 4px 0 2px;
}

.dialog-detail {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.dialog-form .form-group:last-of-type {
  margin-bottom: 4px;
}

/* ---------------- 桌面预览（非手机宽度） ---------------- */

@media (min-width: 560px) {
  body {
    background: #dde6f0;
  }

  .app {
    min-height: 100vh;
    box-shadow: 0 0 40px rgba(20, 48, 84, 0.12);
  }

  .tabbar {
    right: auto;
    left: 50%;
    width: 560px;
    transform: translateX(-50%);
  }

  .fab {
    right: calc(50% - 280px + 16px);
  }

  .modal-overlay {
    align-items: center;
    padding: 24px;
  }

  .modal-panel {
    border-radius: 20px;
    max-height: 84vh;
  }

  .toast {
    bottom: 48px;
  }
}

@media (max-width: 359px) {
  .pc-thumb {
    width: 50px;
    height: 50px;
  }

  .bed-badge {
    width: 46px;
  }

  .stat-value {
    font-size: 19px;
  }

  .info-label {
    width: 74px;
  }
}
