/* ===== 安全巡查系统 — PWA 样式 ===== */
:root {
  --c-danger: #e74c3c;
  --c-danger-light: #fde8e8;
  --c-warning: #f39c12;
  --c-warning-light: #fef3e2;
  --c-success: #27ae60;
  --c-success-light: #e8f8ef;
  --c-primary: #3498db;
  --c-primary-light: #e8f4fd;
  --c-bg: #f5f5f5;
  --c-card: #ffffff;
  --c-text: #2c3e50;
  --c-text-light: #7f8c8d;
  --c-border: #ecf0f1;
  --c-divider: #eee;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 12px rgba(0,0,0,.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--c-bg);
  color: var(--c-text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

/* ===== 顶部导航 ===== */
.top-bar {
  position: sticky; top: 0; z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--c-border);
  padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  height: 50px;
}
.top-bar h1 { font-size: 18px; font-weight: 600; }
.top-bar .badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 10px; border-radius: 20px;
}
.badge-danger { background: var(--c-danger-light); color: var(--c-danger); }
.badge-success { background: var(--c-success-light); color: var(--c-success); }

/* ===== 通用卡片 ===== */
.card {
  background: var(--c-card);
  border-radius: var(--radius);
  margin: 12px 16px;
  padding: 16px;
  box-shadow: var(--shadow);
}
.card-sm { padding: 12px; }

/* ===== 按钮 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 46px; padding: 0 24px; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; font-family: var(--font);
  cursor: pointer; transition: all .15s;
  -webkit-appearance: none;
}
.btn:active { transform: scale(0.97); opacity: 0.9; }
.btn-block { width: 100%; }
.btn-danger { background: var(--c-danger); color: #fff; }
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-outline { background: #fff; color: var(--c-primary); border: 1.5px solid var(--c-primary); }
.btn-success-sm { background: var(--c-success-light); color: var(--c-success); font-size: 13px; height: 34px; padding: 0 14px; }

.btn:disabled { opacity: 0.5; pointer-events: none; }

/* ===== 输入框 ===== */
.input-group { margin-bottom: 12px; }
.input-group label { display: block; font-size: 13px; color: var(--c-text-light); margin-bottom: 6px; }
.input {
  width: 100%; height: 46px; padding: 0 14px; border: 1.5px solid var(--c-border);
  border-radius: var(--radius-sm); font-size: 16px; font-family: var(--font);
  background: #fafafa; transition: border .2s;
  -webkit-appearance: none;
}
.input:focus { outline: none; border-color: var(--c-primary); background: #fff; }

/* ===== 状态提示 ===== */
.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 999;
  padding: 10px 24px; border-radius: 20px; font-size: 14px; font-weight: 500;
  box-shadow: 0 4px 16px rgba(0,0,0,.15); animation: toastIn 0.3s ease;
  white-space: nowrap;
}
.toast-success { background: var(--c-success); color: #fff; }
.toast-error { background: var(--c-danger); color: #fff; }
.toast-info { background: var(--c-primary); color: #fff; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(-10px); } }

/* ===== 加载 ===== */
.loading { text-align: center; padding: 40px 0; color: var(--c-text-light); font-size: 14px; }
.spinner {
  display: inline-block; width: 24px; height: 24px;
  border: 3px solid var(--c-border); border-top-color: var(--c-primary);
  border-radius: 50%; animation: spin .6s linear infinite; vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 空状态 ===== */
.empty { text-align: center; padding: 60px 20px; color: var(--c-text-light); }
.empty .icon { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.empty .title { font-size: 15px; font-weight: 500; margin-bottom: 6px; }
.empty .desc { font-size: 13px; }

/* ===== 记录列表 ===== */
.record-item {
  background: var(--c-card); border-radius: var(--radius); margin: 10px 16px;
  padding: 14px; box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.record-item::before {
  content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
}
.record-item.pending::before { background: var(--c-danger); }
.record-item.fixed::before { background: var(--c-success); }
.record-header {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px;
}
.record-header .ws { font-size: 15px; font-weight: 600; }
.record-header .status {
  font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 12px;
}
.status-pending { background: var(--c-danger-light); color: var(--c-danger); }
.status-fixed { background: var(--c-success-light); color: var(--c-success); }
.record-meta { font-size: 13px; color: var(--c-text-light); margin-bottom: 10px; }
.record-actions { display: flex; gap: 8px; }
.record-photo {
  width: 100%; border-radius: var(--radius-sm); margin-top: 10px;
  border: 1px solid var(--c-border); cursor: pointer;
}

/* ===== 仪表盘 ===== */
.dashboard {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 16px;
}
.stat-card {
  background: var(--c-card); border-radius: var(--radius); padding: 14px;
  box-shadow: var(--shadow); text-align: center;
}
.stat-card .num { font-size: 28px; font-weight: 700; line-height: 1.2; }
.stat-card .label { font-size: 12px; color: var(--c-text-light); margin-top: 4px; }
.stat-card.pending .num { color: var(--c-danger); }
.stat-card.today .num { color: var(--c-warning); }
.stat-card.fixed .num { color: var(--c-success); }
.stat-card.total .num { color: var(--c-primary); }

/* ===== 口令页 ===== */
.passcode-page {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; padding: 40px 24px; text-align: center;
}
.passcode-page .icon { font-size: 56px; margin-bottom: 16px; }
.passcode-page h2 { font-size: 20px; margin-bottom: 8px; }
.passcode-page .desc { font-size: 14px; color: var(--c-text-light); margin-bottom: 28px; }
.passcode-page .input { text-align: center; font-size: 20px; letter-spacing: 6px; margin-bottom: 16px; }
.passcode-page .error { color: var(--c-danger); font-size: 13px; margin-bottom: 12px; min-height: 20px; }

/* ===== 拍照区域 ===== */
.camera-area {
  background: #fff; border-radius: var(--radius); margin: 12px 16px;
  padding: 20px; text-align: center; box-shadow: var(--shadow);
  min-height: 200px; display: flex; flex-direction: column;
  align-items: center; justify-content: center; cursor: pointer;
  border: 2px dashed var(--c-border); transition: border .2s;
  position: relative; overflow: hidden;
}
.camera-area:active { border-color: var(--c-primary); }
.camera-area .icon { font-size: 48px; margin-bottom: 10px; opacity: 0.6; }
.camera-area .hint { font-size: 14px; color: var(--c-text-light); }
.camera-area img.preview {
  max-width: 100%; max-height: 320px; border-radius: var(--radius-sm);
}
.preview-bar {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin: 12px 16px;
}
.preview-bar button { flex: 1; }

/* ===== 成功页 ===== */
.result-page {
  text-align: center; padding: 60px 24px;
}
.result-page .icon { font-size: 64px; margin-bottom: 16px; }
.result-page h2 { font-size: 22px; margin-bottom: 8px; }
.result-page .info { 
  background: var(--c-card); border-radius: var(--radius); padding: 20px;
  margin: 24px 0; text-align: left; box-shadow: var(--shadow);
}
.result-page .info .row {
  display: flex; justify-content: space-between; padding: 8px 0;
  border-bottom: 1px solid var(--c-divider); font-size: 14px;
}
.result-page .info .row:last-child { border: none; }
.result-page .info .row .key { color: var(--c-text-light); }
.result-page .info .row .val { font-weight: 500; }

/* ===== 筛选栏 ===== */
.filter-bar {
  display: flex; gap: 8px; padding: 12px 16px;
}
.filter-tag {
  padding: 6px 16px; border-radius: 16px; font-size: 13px; font-weight: 500;
  background: #fff; border: 1px solid var(--c-border); cursor: pointer;
  white-space: nowrap; transition: all .15s;
}
.filter-tag.active { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }

/* ===== 照片弹出 ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200; background: rgba(0,0,0,.85);
  display: flex; align-items: center; justify-content: center;
}
.modal-overlay img {
  max-width: 95%; max-height: 90%; border-radius: 4px;
}
.modal-close {
  position: absolute; top: 20px; right: 20px; width: 36px; height: 36px;
  background: rgba(255,255,255,.2); border-radius: 50%; display: flex;
  align-items: center; justify-content: center; font-size: 20px;
  color: #fff; cursor: pointer;
}

/* ===== 底部安全距离 ===== */
.safe-bottom { height: 20px; }
