/* ========== 设计变量 ========== */
:root {
  --cyan: #4FB3E8;
  --blue: #3B7BDB;
  --blue-deep: #2F63C2;
  --mint: #2FBF9B;
  --mint-soft: #E7F7F3;

  --bg: #F4F7FA;
  --card: #FFFFFF;
  --text: #1F2937;
  --text-sub: #6B7280;
  --text-muted: #9CA3AF;
  --line: #EEF1F5;
  --danger: #E0555B;

  --grad: linear-gradient(135deg, #4FB3E8 0%, #3B7BDB 55%, #2F63C2 100%);
  --shadow-card: 0 8px 24px rgba(31, 64, 120, 0.08);
  --shadow-float: 0 10px 32px rgba(47, 99, 194, 0.28);
}

/* ========== 基础 ========== */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #E8EDF3;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC",
    "MiSans", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
}

body { display: flex; justify-content: center; }

.phone {
  position: relative;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  overflow-x: hidden;
}

/* ========== 视图切换 ========== */
.view { display: none; min-height: 100vh; min-height: 100dvh; }
.view.is-active { display: block; animation: viewIn 0.3s ease both; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ========== 通用按钮 ========== */
.btn-primary {
  display: block;
  width: 100%;
  height: 50px;
  border: none;
  border-radius: 25px;
  background: var(--grad);
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 2px;
  box-shadow: var(--shadow-float);
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, opacity 0.12s ease;
}
.btn-primary:active { transform: scale(0.97); box-shadow: 0 6px 18px rgba(47, 99, 194, 0.22); }
.btn-primary:disabled { opacity: 0.55; box-shadow: none; }

/* ========== 登录视图 ========== */
.login-hero {
  padding: calc(44px + env(safe-area-inset-top)) 28px 0;
  background: var(--grad);
  color: #fff;
  position: relative;
}
.login-hero::after {
  content: "";
  display: block;
  height: 52px;
  margin: 0 -28px;
  background: var(--bg);
  border-radius: 28px 28px 0 0;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-logo {
  width: 52px; height: 52px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.16);
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(6px);
}
.brand-text h1 { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 1px; }
.brand-text p { margin: 3px 0 0; font-size: 13px; opacity: 0.9; }
.brand-sub { margin: 30px 0 0; font-size: 15px; opacity: 0.85; letter-spacing: 0.5px; }

.login-card {
  margin: -20px 20px 0;
  position: relative;
  z-index: 2;
  background: var(--card);
  border-radius: 20px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow-card);
}
.field {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 16px;
  border-radius: 14px;
  background: #F7F9FC;
  border: 1px solid transparent;
  transition: border 0.15s ease, background 0.15s ease;
}
.field + .field { margin-top: 14px; }
.field:focus-within { border-color: var(--blue); background: #fff; }
.field-icon { color: var(--text-muted); display: flex; }
.field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: 16px;
  color: var(--text);
}
.field input::placeholder { color: var(--text-muted); }
.btn-login { margin-top: 22px; }
.login-tip { margin: 16px 0 0; text-align: center; font-size: 12px; color: var(--text-muted); }
.login-tip.error { color: var(--danger); }
.login-footer {
  margin: 26px 0 0;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ========== 首页视图 ========== */
.home-hero {
  background: var(--grad);
  color: #fff;
  padding: calc(18px + env(safe-area-inset-top)) 20px 60px;
  border-radius: 0 0 28px 28px;
}
.home-hero-top { display: flex; align-items: center; justify-content: space-between; }
.doctor-info { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 46px; height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.doctor-name { font-size: 18px; font-weight: 700; }
.doctor-account { font-size: 12px; opacity: 0.85; margin-top: 2px; }
.btn-logout {
  display: flex; align-items: center; gap: 5px;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 18px;
  cursor: pointer;
}
.btn-logout:active { background: rgba(255, 255, 255, 0.28); }

.balance-card {
  margin-top: 26px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 16px;
  padding: 16px 18px;
  backdrop-filter: blur(6px);
}
.balance-label { font-size: 12px; opacity: 0.9; }
.balance-value {
  margin-top: 6px;
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

.search-bar {
  display: flex; gap: 10px;
  margin: -34px 20px 0;
  position: relative;
  z-index: 3;
}
.search-box {
  flex: 1;
  display: flex; align-items: center; gap: 10px;
  height: 52px;
  padding: 0 16px;
  background: #fff;
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  color: var(--text-muted);
}
.search-box input {
  flex: 1; border: none; outline: none;
  font-size: 15px; color: var(--text); background: transparent;
}
.search-box input::placeholder { color: var(--text-muted); }
.search-clear {
  display: none;
  align-items: center; justify-content: center;
  width: 22px; height: 22px;
  border: none;
  background: #eef2f7;
  border-radius: 50%;
  color: #8a94a6;
  cursor: pointer;
  flex: none;
  padding: 0;
}
.search-clear.show { display: flex; }
.btn-search {
  border: none;
  height: 52px;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--grad);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  box-shadow: var(--shadow-float);
  cursor: pointer;
}
.btn-search:active { transform: scale(0.96); }

.list-area { padding: 22px 20px calc(30px + env(safe-area-inset-bottom)); }
.list-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 14px; color: var(--text-sub);
  margin-bottom: 14px;
}
.list-count { color: var(--blue); font-weight: 600; }

.user-list { display: flex; flex-direction: column; gap: 12px; }

.user-item {
  display: flex; align-items: center; gap: 12px;
  background: #fff;
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow-card);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.user-item:active { transform: scale(0.98); }
.user-item-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #EAF3FB;
  color: var(--blue);
  font-size: 18px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
}
.user-item-avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-item-main { flex: 1; min-width: 0; }
.user-item-name { font-size: 16px; font-weight: 600; }
.user-item-service {
  font-size: 12px; color: var(--text-sub);
  margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-item-side { text-align: right; flex-shrink: 0; }
.user-item-period {
  font-size: 12px; color: var(--text-sub);
  padding: 3px 9px;
  background: #F4F7FA;
  border-radius: 10px;
  display: inline-block;
}
.user-item-status {
  display: block; margin-top: 6px;
  font-size: 12px; font-weight: 600;
}
.user-item-status.unuploaded { color: var(--blue); }
.user-item-status.uploaded { color: var(--mint); }

.empty { text-align: center; padding: 60px 20px; }
.empty-icon {
  width: 78px; height: 78px;
  margin: 0 auto;
  border-radius: 50%;
  background: #EEF3FA;
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
}
.empty-title { margin: 18px 0 6px; font-size: 15px; color: var(--text-sub); font-weight: 600; }
.empty-desc { margin: 0; font-size: 13px; color: var(--text-muted); }

/* ========== 上传报告视图 ========== */
.upload-hero {
  background: var(--grad);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top)) 20px 22px;
  border-radius: 0 0 26px 26px;
  display: flex; align-items: center; gap: 12px;
}
.btn-back {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}
.btn-back:active { background: rgba(255, 255, 255, 0.28); }
.upload-hero-store { font-size: 16px; font-weight: 700; }
.upload-hero-tel { font-size: 12px; opacity: 0.9; margin-top: 2px; font-variant-numeric: tabular-nums; }

.upload-body { padding: 18px 20px calc(34px + env(safe-area-inset-bottom)); }

.user-card {
  display: flex; align-items: center; gap: 12px;
  background: #fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-card);
}
.user-card .avatar { background: #EAF3FB; color: var(--blue); }
.user-card-meta { flex: 1; min-width: 0; }
.user-card-name { font-size: 16px; font-weight: 600; }
.user-card-service {
  font-size: 12px; color: var(--text-sub);
  margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.user-card-time {
  font-size: 12px; color: var(--text-sub);
  padding: 3px 10px; background: #F4F7FA; border-radius: 10px;
  flex-shrink: 0;
}

.section { margin-top: 22px; }
.section-title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 12px; }

.category-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.category-item {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 14px;
  padding: 14px 12px;
  text-align: center;
  font-size: 14px;
  color: var(--text-sub);
  cursor: pointer;
  transition: all 0.15s ease;
}
.category-item:active { transform: scale(0.97); }
.category-item.is-selected {
  border-color: var(--blue);
  background: #EEF5FF;
  color: var(--blue);
  font-weight: 600;
}

.uploader {
  position: relative;
  border: 1.5px dashed #CBD5E1;
  border-radius: 16px;
  background: #FBFCFE;
  overflow: hidden;
  cursor: pointer;
  transition: border 0.15s ease;
}
.uploader:active { border-color: var(--blue); }
.uploader-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 30px 16px;
  color: var(--text-sub);
}
.uploader-empty p { margin: 10px 0 4px; font-size: 15px; }
.uploader-empty span { font-size: 12px; color: var(--text-muted); }
.uploader-plus {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: #EEF5FF;
  color: var(--blue);
  display: flex; align-items: center; justify-content: center;
}

.uploader-preview { position: relative; }
.uploader-preview img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
}
.uploader-delete {
  position: absolute;
  right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 4px;
  border: none;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 16px;
  cursor: pointer;
}

.btn-submit { margin-top: 26px; }
.upload-note { margin: 12px 0 0; text-align: center; font-size: 12px; color: var(--text-muted); }

/* ========== Toast ========== */
.toast {
  position: fixed;
  left: 50%;
  top: 18%;
  transform: translateX(-50%) translateY(-10px);
  background: rgba(17, 24, 39, 0.92);
  color: #fff;
  font-size: 14px;
  padding: 11px 20px;
  border-radius: 22px;
  max-width: 80%;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 999;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== 弹层 ========== */
.modal-mask {
  position: fixed; inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: none;
  align-items: center; justify-content: center;
  z-index: 1000;
  padding: 40px 28px;
}
.modal-mask.show { display: flex; animation: viewIn 0.2s ease both; }
.modal {
  width: 100%;
  max-width: 320px;
  background: #fff;
  border-radius: 20px;
  padding: 28px 24px 22px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
}
.modal-icon {
  width: 56px; height: 56px;
  margin: 0 auto 14px;
  border-radius: 50%;
  background: #FDECEC;
  color: var(--danger);
  display: flex; align-items: center; justify-content: center;
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-text { margin: 8px 0 22px; font-size: 14px; color: var(--text-sub); }
.modal-actions { display: flex; gap: 12px; }
.btn-modal {
  flex: 1;
  height: 46px;
  border: none;
  border-radius: 23px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn-cancel { background: #F4F7FA; color: var(--text-sub); }
.btn-cancel:active { background: #E9EEF5; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:active { background: #C94A50; }

/* 加载遮罩 */
.loading {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }