/* ─── Patrol System — Mobile-first, Gold Theme ─── */
:root {
  --bg-deep: #020408;
  --bg-card: #0a1020;
  --bg-input: #101828;
  --bg-surface: #0d1424;
  --text-primary: #f0f4f8;
  --text-secondary: rgba(200,210,225,0.6);
  --text-muted: rgba(180,190,210,0.45);
  --gold: #c9a962;
  --gold-soft: rgba(201,169,98,0.7);
  --gold-glow: rgba(201,169,98,0.15);
  --green: #4ade80;
  --red: #f87171;
  --orange: #fb923c;
  --line: rgba(255,255,255,0.06);
  --line-gold: rgba(201,169,98,0.25);
  --radius: 12px;
  --radius-sm: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; min-height: 100vh;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ─── Header ─── */
.header {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  height: 52px; padding: 0 16px;
  background: rgba(2,4,8,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.header-title { font-size: 17px; font-weight: 600; color: var(--gold); }
.header-left, .header-right { min-width: 48px; display: flex; align-items: center; }
.header-right { justify-content: flex-end; }
.btn-icon {
  width: 36px; height: 36px; border: none; background: none;
  color: var(--text-primary); font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
}
.btn-icon:active { background: var(--gold-glow); }
.user-badge { font-size: 13px; color: var(--gold-soft); }
.hidden { display: none !important; }

/* ─── Page content ─── */
.page-content { padding: 16px; padding-bottom: 100px; }

/* ─── Cards ─── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  transition: border-color 0.2s;
}
.card:active { border-color: var(--line-gold); }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.card-title { font-size: 16px; font-weight: 600; }
.card-subtitle { font-size: 13px; color: var(--text-secondary); }
.card-row { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-secondary); margin-top: 4px; }

/* ─── Section ─── */
.section { margin-bottom: 20px; }
.section-title {
  font-size: 14px; font-weight: 600; color: var(--gold);
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 10px; padding-bottom: 6px;
  border-bottom: 1px solid var(--line-gold);
}

/* ─── Progress bar ─── */
.progress-bar { width: 100%; height: 6px; background: var(--bg-input); border-radius: 3px; overflow: hidden; margin: 12px 0; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--gold), #e0c975); border-radius: 3px; transition: width 0.4s ease; }

/* ─── Status badges ─── */
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 10px;
  font-size: 12px; font-weight: 500;
}
.badge-pending { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-completed { background: rgba(74,222,128,0.15); color: var(--green); }
.badge-issue { background: rgba(248,113,113,0.15); color: var(--red); }
.badge-pass { background: rgba(74,222,128,0.15); color: var(--green); }

/* ─── Buttons ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  height: 48px; padding: 0 24px; border: none; border-radius: var(--radius-sm);
  font-size: 15px; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.btn-primary { background: var(--gold); color: #020408; width: 100%; }
.btn-primary:active { background: #b8963d; }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-outline {
  background: transparent; border: 1px solid var(--line-gold);
  color: var(--gold); width: 100%;
}
.btn-outline:active { background: var(--gold-glow); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 13px; }
.btn-danger { background: rgba(248,113,113,0.15); color: var(--red); border: 1px solid rgba(248,113,113,0.2); }

/* ─── Form elements ─── */
.form-group { margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; }
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 12px; border-radius: var(--radius-sm);
  background: var(--bg-input); border: 1px solid var(--line);
  color: var(--text-primary); font-size: 15px;
}
.form-input:focus, .form-textarea:focus { border-color: var(--gold); outline: none; }
.form-textarea { min-height: 80px; resize: vertical; }

/* ─── Checklist items ─── */
.check-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--line);
}
.check-item:last-child { border-bottom: none; }
.check-label { flex: 1; font-size: 14px; }
.check-btns { display: flex; gap: 8px; }
.check-btn {
  width: 44px; height: 36px; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--bg-input);
  color: var(--text-secondary); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.check-btn.active-ok { background: rgba(74,222,128,0.15); border-color: var(--green); color: var(--green); }
.check-btn.active-issue { background: rgba(248,113,113,0.15); border-color: var(--red); color: var(--red); }

/* ─── Issue expand panel ─── */
.issue-panel {
  padding: 10px 0 10px 16px; display: none;
  border-left: 2px solid var(--red);
  margin-left: 8px; margin-bottom: 8px;
}
.issue-panel.open { display: block; }

/* ─── Severity selector ─── */
.severity-group { display: flex; gap: 6px; margin: 8px 0; }
.severity-btn {
  padding: 4px 12px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-input); color: var(--text-secondary);
  font-size: 12px; cursor: pointer;
}
.severity-btn.active { border-color: var(--gold); color: var(--gold); background: var(--gold-glow); }

/* ─── Photo upload ─── */
.photo-upload {
  display: flex; align-items: center; justify-content: center;
  width: 100%; height: 120px; border: 2px dashed var(--line-gold);
  border-radius: var(--radius); cursor: pointer;
  color: var(--gold-soft); font-size: 14px;
  transition: all 0.2s;
}
.photo-upload:active { border-color: var(--gold); background: var(--gold-glow); }
.photo-preview { max-width: 100%; max-height: 160px; border-radius: var(--radius-sm); margin-top: 8px; }

/* ─── Alert banner ─── */
.alert {
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 12px; font-size: 13px;
}
.alert-warning { background: rgba(251,191,36,0.12); border: 1px solid rgba(251,191,36,0.3); color: #fbbf24; }
.alert-danger { background: rgba(248,113,113,0.12); border: 1px solid rgba(248,113,113,0.3); color: var(--red); }
.alert-info { background: rgba(96,165,250,0.12); border: 1px solid rgba(96,165,250,0.3); color: #60a5fa; }
.alert-success { background: rgba(74,222,128,0.12); border: 1px solid rgba(74,222,128,0.3); color: var(--green); }

/* ─── Sticky submit ─── */
.sticky-bottom {
  position: fixed; bottom: 0; left: 0; right: 0;
  padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(2,4,8,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 100;
}

/* ─── Temperature display ─── */
.temp-display {
  display: flex; align-items: center; justify-content: center;
  padding: 16px; border-radius: var(--radius);
  background: var(--bg-surface); margin: 10px 0;
}
.temp-value { font-size: 42px; font-weight: 700; color: var(--gold); }
.temp-unit { font-size: 18px; color: var(--text-secondary); margin-left: 4px; }
.temp-confidence { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ─── Loading spinner ─── */
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--line);
  border-top-color: var(--gold); border-radius: 50%;
  animation: spin 0.8s linear infinite; margin: 20px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Login page ─── */
.login-container {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; min-height: 80vh; text-align: center;
}
.login-logo { font-size: 48px; margin-bottom: 16px; }
.login-title { font-size: 22px; font-weight: 600; color: var(--gold); margin-bottom: 8px; }
.login-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 32px; }

/* ─── Tabs ─── */
.tabs { display: flex; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tab {
  flex: 1; padding: 10px; text-align: center; font-size: 14px;
  color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent;
  transition: all 0.2s;
}
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ─── Nav bar (bottom) ─── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0;
  display: flex; height: 56px;
  background: rgba(2,4,8,0.95);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  z-index: 99;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; font-size: 11px; color: var(--text-secondary);
  cursor: pointer; text-decoration: none;
}
.nav-item.active { color: var(--gold); }
.nav-icon { font-size: 22px; margin-bottom: 2px; }

/* ─── Empty state ─── */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-secondary); font-size: 14px;
}

/* ─── Toast notification ─── */
.toast {
  position: fixed; top: 60px; left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: var(--radius-sm);
  background: var(--bg-card); border: 1px solid var(--line-gold);
  color: var(--text-primary); font-size: 14px; z-index: 200;
  opacity: 0; transition: opacity 0.3s;
}
.toast.show { opacity: 1; }

/* ─── Photo thumbnails ─── */
.photo-thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.photo-thumb {
  width: 60px; height: 60px; border-radius: var(--radius-sm);
  object-fit: cover; border: 1px solid var(--line);
}

/* ─── Incomplete check item (validation highlight) ─── */
.check-item.incomplete {
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  animation: flash-red 0.6s ease 2;
}
@keyframes flash-red {
  0%, 100% { border-color: var(--red); }
  50% { border-color: transparent; }
}

/* ─── Progress section (Scheme 4) ─── */
.progress-section {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.progress-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 6px;
}
.progress-label { font-size: 13px; color: var(--text-secondary); }
.progress-count { font-size: 14px; font-weight: 600; color: var(--gold); }
.cat-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.cat-tag {
  font-size: 12px; padding: 2px 8px; border-radius: 10px;
  background: var(--bg-input); color: var(--text-secondary);
  border: 1px solid var(--line);
}
.cat-tag.cat-done { border-color: var(--green); color: var(--green); background: rgba(74,222,128,0.08); }

/* ─── Section count badge ─── */
.section-count { font-size: 12px; font-weight: 400; color: var(--text-secondary); }

/* ─── Photo time warning (EXIF, Scheme 5) ─── */
.alert-photo-time {
  background: rgba(251,146,60,0.12);
  border: 1px solid rgba(251,146,60,0.3);
  color: var(--orange);
}
