/* ===== 全局变量 ===== */
:root {
  --primary: #1a5276;
  --primary-light: #2980b9;
  --success: #27ae60;
  --success-light: #eafaf1;
  --danger: #e74c3c;
  --danger-light: #fdedec;
  --warning: #f39c12;
  --warning-light: #fef9e7;
  --bg: #f0f2f5;
  --card: #ffffff;
  --text: #2c3e50;
  --text-secondary: #7f8c8d;
  --text-muted: #bdc3c7;
  --border: #e8eaed;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --bottom-nav-h: 64px;
  --header-h: 52px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ===== 基础重置 ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

/* ===== 应用外壳 ===== */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

/* ===== 顶部栏 ===== */
#header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: 0.5px;
}
#header .header-icon { font-size: 20px; margin-right: 8px; }
#header .header-back {
  background: none; border: none; color: white; font-size: 22px;
  padding: 4px 8px; margin-right: 8px; cursor: pointer;
}

/* ===== 主内容区 ===== */
#content {
  padding: 12px 16px 80px;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== 卡片 ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
}
.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text);
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ===== 按钮 ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.2s;
  min-height: 44px;
  gap: 8px;
}
.btn:active { opacity: 0.8; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-outline { background: white; color: var(--primary); border: 1.5px solid var(--primary); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 16px 32px; font-size: 17px; border-radius: var(--radius); }
.btn-sm { padding: 8px 16px; font-size: 13px; min-height: 36px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===== 底部导航 ===== */
#bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 480px;
  margin: 0 auto;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
  gap: 3px;
}
.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 22px; line-height: 1; }
.nav-item .nav-label { font-size: 11px; }

/* ===== 统计卡片 ===== */
.stat-row {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}
.stat-card {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
.stat-value.green { color: var(--success); }
.stat-value.red { color: var(--danger); }
.stat-value.warn { color: var(--warning); }
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== 列表 ===== */
.list-item {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  gap: 12px;
}
.list-item:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.list-item:last-child { border-radius: 0 0 var(--radius) var(--radius); border-bottom: none; }
.list-item:only-child { border-radius: var(--radius); }
.list-item-thumb {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--bg); display: flex; align-items: center;
  justify-content: center; font-size: 18px; flex-shrink: 0;
  object-fit: cover;
}
.list-item-info { flex: 1; min-width: 0; }
.list-item-title { font-size: 15px; font-weight: 500; }
.list-item-desc { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }
.list-item-action { color: var(--text-muted); font-size: 13px; }

/* ===== 表单 ===== */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}
.form-input {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  transition: border-color 0.2s;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.form-select {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  appearance: none;
}

/* ===== 摄像头区域 ===== */
.camera-container {
  position: relative;
  width: 100%;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 12px;
}
.camera-container video, .camera-container canvas {
  width: 100%;
  display: block;
  border-radius: var(--radius);
}
.camera-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(0,0,0,0.6);
  color: white;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.camera-overlay .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--danger);
  animation: pulse 1.5s infinite;
}
.camera-overlay .dot.active { background: var(--success); animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== 进度标签 ===== */
.tag {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.tag-success { background: var(--success-light); color: var(--success); }
.tag-warning { background: var(--warning-light); color: var(--warning); }
.tag-danger { background: var(--danger-light); color: var(--danger); }
.tag-info { background: #eaf2f8; color: var(--primary); }

/* ===== 空状态 ===== */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-secondary);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state .empty-text { font-size: 15px; margin-bottom: 16px; }

/* ===== 模态框 ===== */
.modal-mask {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-end;
}
.modal-sheet {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  max-height: 80vh;
  background: var(--card);
  border-radius: 16px 16px 0 0;
  overflow-y: auto;
  padding: 20px 16px;
  padding-bottom: calc(20px + var(--safe-bottom));
}
.modal-sheet-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 16px;
  text-align: center;
}
.modal-sheet .close-btn {
  position: absolute;
  right: 16px; top: 20px;
  background: var(--bg); border: none;
  width: 28px; height: 28px; border-radius: 50%;
  font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ===== 成员勾选列表 ===== */
.member-check-list { max-height: 240px; overflow-y: auto; }
.member-check-item {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.member-check-item input[type="checkbox"] {
  width: 20px; height: 20px; accent-color: var(--primary);
}

/* ===== 报告区域 ===== */
.report-section { margin-bottom: 16px; }
.report-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.report-table th, .report-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.report-table th { color: var(--text-secondary); font-weight: 500; }

/* ===== 提示条 ===== */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 300;
  animation: toastIn 0.3s ease;
  max-width: 90%;
  text-align: center;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===== 确认对话框 ===== */
.confirm-dialog {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  z-index: 250;
  text-align: center;
  width: 280px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
}
.confirm-dialog p { margin-bottom: 20px; font-size: 15px; }
.confirm-dialog .btn-row { display: flex; gap: 12px; }
.confirm-dialog .btn-row .btn { flex: 1; }

/* ===== 滚动区域 ===== */
.scroll-area { max-height: calc(100vh - 200px); overflow-y: auto; }

/* ===== 监控状态摘要 ===== */
.monitor-summary {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.monitor-summary-item {
  background: var(--card);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
  box-shadow: var(--shadow);
}
.monitor-summary-item .val {
  font-size: 24px; font-weight: 700; color: var(--primary);
}
.monitor-summary-item .lbl {
  font-size: 12px; color: var(--text-secondary); margin-top: 2px;
}

/* ===== 响应式微调 ===== */
@media (min-width: 480px) {
  #app { border-left: 1px solid var(--border); border-right: 1px solid var(--border); }
}

/* ===== 拍照间隔虚拟旋钮 ===== */
.knob-wrap { display:flex; flex-direction:column; align-items:center; gap:8px; padding:4px 0 2px; }
.knob {
  position:relative; width:150px; height:150px; border-radius:50%;
  background: radial-gradient(circle at 35% 30%, #fff, #dfe6ee);
  border:2px solid var(--primary-light);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.12), 0 2px 6px rgba(0,0,0,.15);
  touch-action:none; cursor:grab; user-select:none; -webkit-user-select:none;
}
.knob:active { cursor:grabbing; }
.knob::before {
  content:""; position:absolute; inset:6px; border-radius:50%;
  background: repeating-conic-gradient(from -90deg, var(--primary-light) 0deg 1deg, transparent 1deg 15deg);
  opacity:.35;
}
.knob-shaft {
  position:absolute; left:50%; top:6px; width:3px; height:calc(50% - 6px);
  margin-left:-1.5px; background:var(--primary); border-radius:2px;
  transform-origin:50% 100%;
}
.knob-center {
  position:absolute; inset:0; display:flex; align-items:center; justify-content:center;
  gap:2px; font-size:26px; font-weight:700; color:var(--text); pointer-events:none;
}
.knob-unit { font-size:13px; color:var(--text-secondary); font-weight:500; }
.knob-hint { font-size:12px; color:var(--text-muted); }
