/* ========== RESET & BASE ========== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --danger: #ef4444;
  --danger-light: #fca5a5;
  --warning: #f59e0b;
  --warning-light: #fcd34d;
  --success: #22c55e;
  --success-light: #86efac;
  --bg: #f8fafc;
  --card: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-tertiary: #94a3b8;
  --border: #e2e8f0;
  --tab-height: 83px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

body {
  font-family: -apple-system, SF Pro Display, SF Pro Text, Helvetica Neue, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  max-width: 428px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  overflow: hidden;
}

.hidden { display: none !important; }

/* ========== PAGES CONTAINER ========== */
.pages-container {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
}

.page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  transform: translateX(20px);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  padding-bottom: var(--tab-height);
}

.page.active {
  opacity: 1;
  transform: translateX(0);
  pointer-events: auto;
}

.page::-webkit-scrollbar { display: none; }

/* ========== TAB BAR ========== */
.tab-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 428px;
  height: var(--tab-height);
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid rgba(0,0,0,0.08);
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding-top: 8px;
  padding-bottom: var(--safe-bottom);
  z-index: 100;
}

.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.2s;
  padding: 4px 16px;
}

.tab-item:active { transform: scale(0.9); }

.tab-item svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: var(--text-tertiary);
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: all 0.25s;
}

.tab-item span {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-tertiary);
  transition: color 0.25s;
}

.tab-item.active svg {
  stroke: var(--primary);
  transform: scale(1.05);
}

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

/* ========== ANIMATIONS ========== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pulse-ring {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.5); opacity: 0; }
}

@keyframes scan-rotate {
  0% { transform: translate(-50%, -50%) rotate(0deg); }
  100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes progress-glow {
  0%, 100% { box-shadow: 0 0 8px rgba(37,99,235,0.4); }
  50% { box-shadow: 0 0 20px rgba(37,99,235,0.7); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

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

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

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

@keyframes slideInFromRight {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes countUp {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* ========== COMMON ========== */
.section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 12px;
  padding: 0 16px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.pill-danger { background: #fef2f2; color: var(--danger); }
.pill-warning { background: #fffbeb; color: var(--warning); }
.pill-success { background: #f0fdf4; color: var(--success); }

/* 整改状态标签 */
.pill-rect-pending { background: #fffbeb; color: #b45309; }
.pill-rect-verified { background: #f0fdf4; color: #15803d; }

/* 记录卡片多标签容器 */
.record-badges { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
}

.spinner-sm {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(0,0,0,0.1);
  border-top-color: var(--primary);
}

/* ========== PAGE 1: 拍照页 ========== */
.page-camera {
  background: var(--bg);
}

.camera-header {
  background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 50%, #3b82f6 100%);
  padding: calc(var(--safe-top) + 16px) 20px 24px;
  border-radius: 0 0 24px 24px;
  position: relative;
  overflow: hidden;
}

.camera-header::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -20%;
  width: 200px;
  height: 200px;
  background: rgba(255,255,255,0.06);
  border-radius: 50%;
}

.camera-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: relative;
  z-index: 2;
}

.camera-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.camera-header-subtitle {
  font-size: 13px;
  color: rgba(255,255,255,0.7);
  margin-top: 4px;
}

.camera-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #60a5fa, #a78bfa);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255,255,255,0.3);
}

.camera-header-avatar svg { width: 22px; height: 22px; }

/* Stats bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 0 16px;
  margin-top: -20px;
  position: relative;
  z-index: 10;
}

.stat-card {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 12px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,0.08);
  animation: fadeInUp 0.5s ease-out backwards;
}

.stat-num {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
}

.stat-num-primary { color: var(--primary); }
.stat-num-warning { color: var(--warning); }
.stat-num-success { color: var(--success); }

.stat-label {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  font-weight: 500;
}

/* 可点击统计卡片 */
.stat-card-clickable {
  cursor: pointer;
  position: relative;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: 18px;
}

.stat-card-clickable:active {
  transform: scale(0.94);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

.stat-card-clickable:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.12);
}

.stat-card-arrow {
  position: absolute;
  bottom: 6px;
  right: 8px;
  width: 12px;
  height: 12px;
  color: var(--text-tertiary);
  opacity: 0.5;
  transition: opacity 0.2s, transform 0.2s;
}

.stat-card-clickable:active .stat-card-arrow {
  opacity: 1;
  transform: translateX(2px);
}

/* 点击涟漪动画 */
@keyframes statCardTap {
  0% { transform: scale(1); }
  50% { transform: scale(0.94); }
  100% { transform: scale(1); }
}

.stat-card-tap {
  animation: statCardTap 0.3s ease-out;
}

/* Camera area */
.camera-area {
  margin: 20px 16px 16px;
  background: var(--card);
  border-radius: 20px;
  padding: 32px 20px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s;
}

.camera-area:active { transform: scale(0.98); }

.camera-icon-wrap {
  width: 80px;
  height: 80px;
  margin: 0 auto 16px;
  position: relative;
}

.camera-icon-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px dashed var(--primary-light);
  animation: rotate-ring 12s linear infinite;
}

.camera-icon-inner {
  position: absolute;
  inset: 8px;
  background: linear-gradient(135deg, #dbeafe, #eff6ff);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.camera-icon-inner svg {
  width: 32px;
  height: 32px;
}

.camera-text {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.camera-subtext {
  font-size: 12px;
  color: var(--text-tertiary);
}

/* Preview area */
.preview-area {
  margin: 20px 16px 0;
  border-radius: 20px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  animation: fadeIn 0.3s ease-out;
}

.preview-area img {
  width: 100%;
  display: block;
  max-height: 240px;
  object-fit: cover;
}

.preview-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s;
}

.preview-close:active { transform: scale(0.9); }
.preview-close svg { width: 16px; height: 16px; }

/* Form fields */
.form-section {
  padding: 0 16px;
  margin-top: 16px;
}

.form-field {
  background: var(--card);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.form-field-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.form-field-icon-location {
  background: linear-gradient(135deg, #dbeafe, #eff6ff);
}

.form-field-icon-scene {
  background: linear-gradient(135deg, #fef3c7, #fffbeb);
}

.form-field-icon svg {
  width: 18px;
  height: 18px;
}

.form-field-content { flex: 1; }

.form-field-label {
  font-size: 11px;
  color: var(--text-tertiary);
  font-weight: 500;
  margin-bottom: 4px;
}

.form-field-input,
.form-field-textarea {
  width: 100%;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
  font-weight: 500;
  background: transparent;
  font-family: inherit;
  resize: none;
}

.form-field-input::placeholder,
.form-field-textarea::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
}

.form-field-textarea {
  min-height: 20px;
}

/* Voice button */
.voice-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  background: rgba(37, 99, 235, 0.08);
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  border: none;
  margin-top: 2px;
}

.voice-btn:active { transform: scale(0.92); }

.voice-btn.recording {
  background: var(--danger);
  color: white;
  animation: voicePulse 1.2s ease-in-out infinite;
}

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

/* Submit button */
.submit-btn {
  margin: 20px 16px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #1d4ed8, #2563eb, #3b82f6);
  border: none;
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  box-shadow: 0 8px 24px rgba(37,99,235,0.3);
  transition: all 0.2s;
  letter-spacing: 0.3px;
}

.submit-btn:active:not(:disabled) {
  transform: scale(0.97);
  box-shadow: 0 4px 12px rgba(37,99,235,0.2);
}

.submit-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  box-shadow: none;
}

.submit-btn .btn-arrow {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.btn-loading .spinner {
  margin-right: 6px;
}

/* ========== PAGE 2: 分析等待页 ========== */
.page-waiting {
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 0 !important;
}

.scan-container {
  position: relative;
  width: 220px;
  height: 220px;
  margin-bottom: 40px;
}

.scan-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 40px rgba(37,99,235,0.5);
}

.scan-core svg {
  width: 36px;
  height: 36px;
}

.scan-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1.5px solid rgba(37,99,235,0.3);
}

.scan-ring-1 { width: 120px; height: 120px; animation: pulse-ring 2s ease-out infinite; }
.scan-ring-2 { width: 120px; height: 120px; animation: pulse-ring 2s ease-out infinite 0.7s; }
.scan-ring-3 { width: 120px; height: 120px; animation: pulse-ring 2s ease-out infinite 1.4s; }

.scan-line-wrap {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 180px;
  height: 180px;
  animation: scan-rotate 3s linear infinite;
}

.scan-line {
  position: absolute;
  top: 0;
  left: 50%;
  width: 2px;
  height: 50%;
  background: linear-gradient(to bottom, var(--primary), transparent);
  transform-origin: bottom center;
  border-radius: 1px;
}

.waiting-title {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  margin-bottom: 8px;
  text-align: center;
}

.waiting-subtitle {
  font-size: 14px;
  color: rgba(255,255,255,0.5);
  margin-bottom: 40px;
  text-align: center;
}

.progress-wrap {
  width: 260px;
  margin-bottom: 12px;
}

.progress-track {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #60a5fa);
  border-radius: 3px;
  animation: progress-glow 2s ease-in-out infinite;
  transition: width 0.5s;
}

.waiting-percent {
  text-align: center;
  font-size: 14px;
  color: var(--primary-light);
  font-weight: 600;
  margin-bottom: 8px;
}

.waiting-eta {
  text-align: center;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

.waiting-cancel {
  margin-top: 60px;
  font-size: 15px;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  border: none;
  background: none;
  padding: 10px 24px;
  transition: color 0.2s;
}

.waiting-cancel:hover { color: rgba(255,255,255,0.8); }

/* ========== PAGE 3: 隐患报告详情页 ========== */
.page-report,
.page-history-detail {
  background: var(--bg);
}

.report-nav {
  padding: calc(var(--safe-top) + 8px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(248,250,252,0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.report-nav-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--card);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  cursor: pointer;
  transition: transform 0.2s;
}

.report-nav-btn:active { transform: scale(0.92); }

.report-nav-btn svg {
  width: 18px;
  height: 18px;
}

.report-nav-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

.report-body {
  padding-top: 12px;
  padding-bottom: 40px;
}

/* Risk card */
.risk-card {
  margin: 0 16px 16px;
  border-radius: 20px;
  padding: 24px;
  position: relative;
  overflow: hidden;
  color: #fff;
  animation: fadeInUp 0.5s ease-out backwards;
}

.risk-card.risk-medium {
  background: linear-gradient(135deg, #d97706, #f59e0b, #fbbf24);
}

/* [UX-FIX] 风险等级配色优化：避免绿色+隐患的认知矛盾 */
.risk-card.risk-high {
  background: linear-gradient(135deg, #dc2626, #ef4444, #f87171);
}
.risk-card.risk-low {
  background: linear-gradient(135deg, #0891b2, #06b6d4, #22d3ee);
}
.risk-card.risk-safe {
  background: linear-gradient(135deg, #16a34a, #22c55e, #4ade80);
}
/* [UX-FIX] 重大隐患时增加呼吸闪烁效果，引起高度重视 */
.risk-card.risk-critical {
  background: linear-gradient(135deg, #991b1b, #dc2626, #ef4444);
  animation: fadeInUp 0.5s ease-out backwards, criticalPulse 2s ease-in-out infinite;
}
@keyframes criticalPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,0.4); }
  50% { box-shadow: 0 0 20px 4px rgba(220,38,38,0.2); }
}

.risk-card::after {
  content: '';
  position: absolute;
  top: -30px;
  right: -30px;
  width: 120px;
  height: 120px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}

.risk-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  position: relative;
  z-index: 2;
}

.risk-icon {
  width: 44px;
  height: 44px;
  background: rgba(255,255,255,0.2);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.risk-icon svg {
  width: 24px;
  height: 24px;
}

.risk-level-text {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 1px;
}

.risk-desc {
  font-size: 14px;
  opacity: 0.9;
  position: relative;
  z-index: 2;
}

/* Summary card */
.summary-card {
  margin: 0 16px 16px;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.summary-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.summary-text {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Photo section */
.photo-section {
  margin-bottom: 16px;
}

.photo-wrap {
  display: block;
  padding: 0 16px;
  overflow: visible;
}

.photo-wrap::-webkit-scrollbar { display: none; }

.photo-thumb {
  width: 100%;
  height: auto;
  border-radius: 12px;
  overflow: hidden;
  position: relative;
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  max-height: 300px;
  object-fit: contain;
}

/* Photo tabs */
.photo-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary, #f0f0f0);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 8px;
}

.photo-tab {
  flex: 1;
  text-align: center;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-secondary, #666);
  transition: all 0.2s ease;
  user-select: none;
}

.photo-tab.active {
  background: var(--card, #fff);
  color: var(--text-primary, #333);
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

.photo-tab-content .photo-thumb {
  width: 100%;
  height: auto;
  border-radius: 12px;
  overflow: hidden;
}

.photo-tab-content .photo-thumb img {
  width: 100%;
  height: auto;
  object-fit: contain;
  max-height: 300px;
}

/* Hazard annotated image */
.hazard-annotated-img {
  margin: 8px 0;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
}

.hazard-annotated-img img {
  width: 100%;
  height: auto;
  max-height: 200px;
  object-fit: cover;
}

/* Hazard list */
.hazard-section {
  margin-bottom: 16px;
}

.hazard-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin: 0 16px 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  border-left: 4px solid;
  animation: fadeInUp 0.5s ease-out backwards;
}

.hazard-card.high { border-left-color: var(--danger); }
.hazard-card.medium { border-left-color: var(--warning); }
.hazard-card.low { border-left-color: var(--success); }

.hazard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.hazard-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.hazard-desc {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}

.hazard-ref {
  background: #eff6ff;
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.hazard-ref-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.hazard-ref-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--primary);
  stroke-width: 2;
}

.hazard-ref-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.hazard-ref-text {
  font-size: 12px;
  color: #3b82f6;
  line-height: 1.5;
}

.hazard-fix {
  background: #f0fdf4;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}

.hazard-fix-icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
}

.hazard-fix-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: #16a34a;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hazard-fix-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  white-space: nowrap;
}

.hazard-fix-text {
  font-size: 12px;
  color: #16a34a;
  line-height: 1.5;
}

/* Report meta */
.report-meta {
  margin: 0 16px;
  padding: 12px 16px;
  background: var(--card);
  border-radius: 12px;
  font-size: 12px;
  color: var(--text-tertiary);
  text-align: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

/* Retake button */
.report-retake-btn {
  margin: 20px 16px 40px;
  height: 52px;
  border-radius: 14px;
  background: var(--card);
  border: 1.5px solid var(--border);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 32px);
  transition: all 0.2s;
}

.report-retake-btn:active { transform: scale(0.97); background: #f1f5f9; }

.report-retake-btn svg {
  width: 20px;
  height: 20px;
}

/* ========== PAGE 4: 历史记录列表页 ========== */
.page-history {
  background: var(--bg);
}

.history-header {
  padding: calc(var(--safe-top) + 12px) 20px 16px;
  background: rgba(248,250,252,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.history-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* Filter tabs */
.filter-tabs {
  display: flex;
  gap: 6px;
  padding: 0 16px;
  margin-bottom: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.25s;
  background: var(--card);
  color: var(--text-secondary);
  border: 1.5px solid transparent;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.filter-tab.active {
  background: #eff6ff;
  color: var(--primary);
  border-color: var(--primary);
}

.filter-tab:active { transform: scale(0.95); }

/* Record list */
.record-list {
  padding: 0 16px;
}

.record-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 10px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.2s;
  animation: fadeInUp 0.5s ease-out backwards;
}

.record-card:active { transform: scale(0.98); }

.record-thumb {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.record-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.record-thumb svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: rgba(255,255,255,0.8);
  stroke-width: 1.5;
}

.record-thumb-1 { background: linear-gradient(135deg, #fca5a5, #f87171); }
.record-thumb-2 { background: linear-gradient(135deg, #fde68a, #fbbf24); }
.record-thumb-3 { background: linear-gradient(135deg, #86efac, #4ade80); }
.record-thumb-4 { background: linear-gradient(135deg, #93c5fd, #3b82f6); }
.record-thumb-5 { background: linear-gradient(135deg, #c4b5fd, #8b5cf6); }
.record-thumb-6 { background: linear-gradient(135deg, #fdba74, #f97316); }

.record-info {
  flex: 1;
  min-width: 0;
}

.record-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.record-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-tertiary);
}

.record-meta .dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: var(--text-tertiary);
}

.record-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}

.record-arrow {
  width: 18px;
  height: 18px;
}

/* Skeleton */
.skeleton-wrap {
  padding: 0 16px;
  margin-top: 12px;
}

.skeleton-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 14px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.skeleton-circle {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
}

.skeleton-lines {
  flex: 1;
}

.skeleton-line {
  height: 12px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  margin-bottom: 8px;
}

.skeleton-line:last-child { margin-bottom: 0; }
.skeleton-line.short { width: 60%; }

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
}

.empty-icon {
  width: 80px;
  height: 80px;
  margin-bottom: 16px;
  opacity: 0.6;
}

.empty-text {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}

.empty-btn {
  padding: 8px 24px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.empty-btn:active { transform: scale(0.95); }

/* Load more */
.load-more {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.load-end {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* ========== PAGE 5: 统计看板页 ========== */
.page-dashboard {
  background: var(--bg);
}

.dashboard-header {
  padding: calc(var(--safe-top) + 12px) 20px 16px;
  background: rgba(248,250,252,0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.dashboard-header h1 {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

/* Segment control */
.segment-control {
  display: flex;
  margin: 0 16px 16px;
  background: var(--card);
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.segment-item {
  flex: 1;
  padding: 10px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s;
}

.segment-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.3);
}

.segment-item:active { transform: scale(0.97); }

/* Metric grid */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 0 16px;
  margin-bottom: 16px;
}

.metric-card {
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
  animation: fadeInUp 0.5s ease-out backwards;
}

.metric-icon {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

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

.metric-icon-blue { background: linear-gradient(135deg, #dbeafe, #eff6ff); }
.metric-icon-blue svg { stroke: var(--primary); }
.metric-icon-red { background: linear-gradient(135deg, #fef2f2, #fff1f2); }
.metric-icon-red svg { stroke: var(--danger); }
.metric-icon-yellow { background: linear-gradient(135deg, #fef9c3, #fefce8); }
.metric-icon-yellow svg { stroke: var(--warning); }
.metric-icon-green { background: linear-gradient(135deg, #dcfce7, #f0fdf4); }
.metric-icon-green svg { stroke: var(--success); }

.metric-num {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.metric-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Chart section */
.chart-section {
  margin: 0 16px 16px;
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.06);
}

.chart-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 16px;
}

/* Donut chart */
.donut-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.donut-svg {
  width: 120px;
  height: 120px;
  transform: rotate(-90deg);
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.legend-label {
  font-size: 13px;
  color: var(--text-secondary);
}

.legend-value {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-left: auto;
}

/* Bar chart */
.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.bar-label {
  font-size: 12px;
  color: var(--text-secondary);
  width: 80px;
  flex-shrink: 0;
  text-align: right;
}

.bar-track {
  flex: 1;
  height: 22px;
  background: #f1f5f9;
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  transition: width 1s ease-out;
  min-width: 30px;
}

/* Line chart */
.line-chart-wrap {
  position: relative;
  height: 140px;
  margin-top: 8px;
}

.line-chart-svg {
  width: 100%;
  height: 100%;
}

/* ========== TOAST ========== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 12px 24px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 500;
  z-index: 1000;
  pointer-events: none;
  animation: fadeIn 0.3s ease-out;
  max-width: 80%;
  text-align: center;
}

/* ========== NETWORK BAR ========== */
.network-bar {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 428px;
  background: var(--danger);
  color: #fff;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  z-index: 200;
  animation: fadeIn 0.3s;
}

/* ========== IMAGE MODAL ========== */
.image-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  cursor: pointer;
  animation: fadeIn 0.2s;
}

.image-modal img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  border-radius: 8px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 375px) {
  .camera-header h1 { font-size: 20px; }
  .stat-num { font-size: 22px; }
  .metric-num { font-size: 24px; }
  .risk-level-text { font-size: 24px; }
}

@media (min-width: 768px) {
  #app {
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}
