/* =============================================
   老年健康评估系统 - 公共样式
   主色调：医疗蓝 #1a6bbd / 辅助绿 #2eaa6b
   ============================================= */

/* ---------- Reset & Base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-tap-highlight-color: transparent; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Hiragino Sans GB',
               'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
  background: #f0f4f8;
  color: #2c3e50;
  min-height: 100vh;
  line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; outline: none; font-family: inherit; }
input, select { font-family: inherit; outline: none; }

/* ---------- CSS 变量 ---------- */
:root {
  --primary: #1a6bbd;
  --primary-dark: #155296;
  --primary-light: #e8f2fc;
  --primary-lighter: #f0f7ff;
  --success: #2eaa6b;
  --success-light: #e8f7f0;
  --warning: #e67e22;
  --warning-light: #fef5e7;
  --danger: #e74c3c;
  --danger-light: #fdecea;
  --gray-1: #f8fafc;
  --gray-2: #f0f4f8;
  --gray-3: #e2e8f0;
  --gray-4: #cbd5e0;
  --gray-5: #a0aec0;
  --gray-6: #718096;
  --gray-7: #4a5568;
  --gray-8: #2d3748;
  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 4px rgba(0,0,0,.08);
  --shadow: 0 2px 12px rgba(0,0,0,.1);
  --shadow-lg: 0 4px 24px rgba(0,0,0,.12);
  --transition: .2s ease;
  --header-h: 56px;
}

/* ---------- 顶部导航栏 ---------- */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(26,107,189,.3);
}

.header-back {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  border-radius: 50%;
  transition: background var(--transition);
  flex-shrink: 0;
}
.header-back:active { background: rgba(255,255,255,.2); }
.header-back svg { width: 20px; height: 20px; }

.header-title {
  flex: 1;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-action {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
  background: transparent;
  border: none;
  border-radius: 50%;
  padding: 0;
  transition: background var(--transition);
}
.header-action:active { background: rgba(255,255,255,.2); }

.header-spacer {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

/* ---------- 页面主体 ---------- */
.page-body {
  margin-top: var(--header-h);
  padding: 16px;
  min-height: calc(100vh - var(--header-h));
}

/* ---------- 卡片 ---------- */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card + .card { margin-top: 12px; }

.card-header {
  display: flex;
  align-items: center;
  padding: 14px 16px 10px;
  border-bottom: 1px solid var(--gray-3);
}

.card-header .card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--gray-8);
  flex: 1;
}

.card-header .card-icon {
  width: 4px; height: 16px;
  background: var(--primary);
  border-radius: 2px;
  margin-right: 8px;
  flex-shrink: 0;
}

.card-body { padding: 14px 16px; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 20px;
  height: 44px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 500;
  transition: all var(--transition);
  white-space: nowrap;
  min-width: 80px;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26,107,189,.35);
}
.btn-primary:active { background: var(--primary-dark); transform: scale(.98); }

.btn-success {
  background: var(--success);
  color: #fff;
  box-shadow: 0 2px 8px rgba(46,170,107,.35);
}
.btn-success:active { background: #25875a; transform: scale(.98); }

.btn-outline {
  background: #fff;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn-outline:active { background: var(--primary-light); }

.btn-gray {
  background: var(--gray-3);
  color: var(--gray-7);
}
.btn-gray:active { background: var(--gray-4); }

.btn-block {
  display: flex;
  width: 100%;
}

.btn-lg { height: 50px; font-size: 16px; border-radius: 12px; }

/* ---------- 表单元素 ---------- */
.form-group { margin-bottom: 14px; }

.form-label {
  display: block;
  font-size: 14px;
  color: var(--gray-7);
  margin-bottom: 6px;
  font-weight: 500;
}

.form-control {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border: 1.5px solid var(--gray-3);
  border-radius: var(--radius-sm);
  font-size: 15px;
  color: var(--gray-8);
  background: #fff;
  transition: border-color var(--transition);
}
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: var(--gray-5); }

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23718096' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ---------- 状态标签 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger  { background: var(--danger-light);  color: var(--danger);  }
.badge-gray    { background: var(--gray-3);         color: var(--gray-6);  }
.badge-primary { background: var(--primary-light);  color: var(--primary); }

/* ---------- 分割线 ---------- */
.divider {
  height: 1px;
  background: var(--gray-3);
  margin: 12px 0;
}

/* ---------- 列表项 ---------- */
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-3);
  transition: background var(--transition);
}
.list-item:last-child { border-bottom: none; }
.list-item:active { background: var(--gray-1); }

.list-item .item-main { flex: 1; min-width: 0; }
.list-item .item-name {
  font-size: 15px;
  font-weight: 500;
  color: var(--gray-8);
  margin-bottom: 3px;
}
.list-item .item-sub {
  font-size: 13px;
  color: var(--gray-6);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-item .item-right {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 12px;
  flex-shrink: 0;
}

/* ---------- 空状态 ---------- */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--gray-5);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: .4; }
.empty-state p { font-size: 15px; }

/* ---------- Loading ---------- */
.loading-mask {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  display: none;
}
.loading-mask.show { display: flex; }
.loading-spinner {
  width: 48px; height: 48px;
  background: #fff;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.loading-spinner::after {
  content: '';
  width: 28px; height: 28px;
  border: 3px solid var(--gray-3);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.9);
  background: rgba(0,0,0,.75);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: all .25s ease;
  white-space: nowrap;
  max-width: 80vw;
  text-align: center;
}
.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ---------- 分页 ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
}
.page-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--gray-7);
  background: #fff;
  border: 1px solid var(--gray-3);
  transition: all var(--transition);
}
.page-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.page-btn:disabled { opacity: .4; pointer-events: none; }
.page-info { font-size: 13px; color: var(--gray-6); padding: 0 4px; }

/* ---------- 人员信息面板 ---------- */
.person-info {
  background: linear-gradient(135deg, var(--primary) 0%, #2980d9 100%);
  padding: 20px 16px;
  color: #fff;
}
.person-info .person-name {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.person-info .person-name .gender-tag {
  font-size: 13px;
  padding: 1px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,.25);
}
.person-info .person-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-top: 12px;
}
.person-info .meta-item {
  font-size: 13px;
  opacity: .9;
  display: flex;
  align-items: center;
  gap: 4px;
}
.person-info .meta-label { opacity: .75; }

/* ---------- 量表卡片 ---------- */
.assess-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.assess-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all var(--transition);
  border: 2px solid transparent;
  position: relative;
  overflow: hidden;
}
.assess-card:active { transform: scale(.97); }
.assess-card.done { border-color: var(--success); }
.assess-card.done::after {
  content: '✓';
  position: absolute;
  top: 6px; right: 8px;
  width: 18px; height: 18px;
  background: var(--success);
  color: #fff;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 18px;
  text-align: center;
}

.assess-card .ac-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  background: var(--ic-bg, #e8f2fc);
  flex-shrink: 0;
}

.assess-card.done .ac-icon {
  background: var(--success-light);
}

.assess-card .ac-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-8);
  line-height: 1.3;
}

/* ---------- 响应式 ---------- */
@media (min-width: 640px) {
  .page-body { padding: 20px; max-width: 720px; margin-left: auto; margin-right: auto; }
  .assess-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 1024px) {
  :root { --header-h: 60px; }
  .app-header { padding: 0 24px; }
  .page-body { max-width: 900px; padding: 24px; }
  .assess-grid { grid-template-columns: repeat(5, 1fr); }
}

/* ---------- 用户信息面板 ---------- */
.user-panel {
  position: fixed;
  inset: 0;
  z-index: 200;
}

.user-panel-mask {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.3);
}

.user-panel-content {
  position: absolute;
  top: var(--header-h);
  right: 12px;
  width: 160px;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,.15);
  padding: 16px 0 10px;
  animation: panelFadeIn .15s ease;
}

@keyframes panelFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.user-panel-avatar {
  width: 48px; height: 48px;
  border-radius: 50%;
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 10px;
}

.user-panel-name {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-8);
}

.user-panel-org {
  text-align: center;
  font-size: 12px;
  color: var(--gray-5);
  margin-top: 3px;
  padding: 0 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-panel-divider {
  height: 1px;
  background: var(--gray-3);
  margin: 14px 0 6px;
}

.user-panel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 20px;
  font-size: 14px;
  color: var(--gray-7);
  background: transparent;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
}
.user-panel-item:active { background: var(--gray-1); }
.user-panel-item svg { flex-shrink: 0; }

.user-panel-logout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 10px 0;
  font-size: 14px;
  color: var(--danger);
  background: transparent;
  border: none;
  border-top: 1px solid var(--gray-3);
  cursor: pointer;
  transition: background var(--transition);
}
.user-panel-logout:active { background: var(--gray-1); }
.user-panel-logout svg { flex-shrink: 0; }

/* ---------- 可搜索下拉框（村居委会等） ---------- */
.cjwh-dropdown {
  position: fixed;
  max-height: 200px;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--gray-3);
  border-radius: var(--radius-sm);
  box-shadow: 0 6px 20px rgba(0,0,0,.12);
  z-index: 500;
  list-style: none;
  padding: 4px 0;
  display: none;
}
.cjwh-dropdown li {
  padding: 10px 14px;
  font-size: 14px;
  color: var(--gray-7);
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cjwh-dropdown li:active,
.cjwh-dropdown li:hover {
  background: var(--primary-light);
  color: var(--primary);
}
.cjwh-dropdown li b {
  color: var(--primary);
  font-weight: 600;
}
