/* ========== STILLWILD Design System ========== */
:root {
  --green-400: #3daa5c;
  --green-500: #2E8B4A;
  --green-600: #267a3f;
  --green-700: #1f5c32;
  --green-800: #163f24;
  --green-900: #0d2818;
  --sand: #f4f1ea;
  --sand-dark: #e6e0d4;
  --cream: #faf8f4;
  --ink: #141a16;
  --muted: #6a7368;
  --white: #ffffff;
  --alert: #dc2626;
  --alert-bg: #fef2f2;
  --warn: #d97706;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 4px 18px rgba(13, 40, 24, 0.07);
  --shadow-lg: 0 12px 36px rgba(13, 40, 24, 0.12);
  --nav-h: 64px;
  --topbar-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--cream);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

h1, h2, h3, h4, .app-title, .brand h1 {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 600;
  letter-spacing: -0.02em;
}

button, input, select, textarea { font-family: inherit; font-size: 15px; }

.hidden { display: none !important; }
/* Developer-only UI (clock sync demo, ICE pairs, …): shown only with ?dev=1 */
html:not(.dev-mode) .dev-only { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 20px; border-radius: 12px; border: none;
  font-weight: 600; cursor: pointer; transition: all 0.15s ease;
}
.btn-primary { background: var(--green-500); color: white; }
.btn-primary:hover { background: var(--green-600); }
.btn-primary:active { transform: scale(0.98); }
.btn-outline { background: transparent; border: 1.5px solid var(--green-500); color: var(--green-600); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 12px; font-size: 13px; border-radius: 9px; }
.link-btn {
  background: none; border: none; color: var(--green-500);
  font-weight: 600; font-size: 13px; cursor: pointer;
}
.icon-btn {
  background: none; border: none; color: var(--ink);
  padding: 8px; border-radius: 10px; cursor: pointer; position: relative;
}
.icon-btn:hover { background: var(--sand-dark); }
.badge-dot {
  position: absolute; top: 6px; right: 6px;
  width: 8px; height: 8px; background: var(--alert);
  border-radius: 50%; border: 2px solid white;
}

/* Auth */
#screen-auth { position: fixed; inset: 0; z-index: 100; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.auth-bg {
  min-height: 100%;
  height: auto;
  background: linear-gradient(165deg, #0d2818 0%, #1f5c32 45%, #2E8B4A 100%);
  display: flex; align-items: flex-end; justify-content: center;
  padding: 24px; position: relative; overflow: visible;
}
.auth-bg::before {
  content: ''; position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 20%, rgba(46,139,74,0.25) 0%, transparent 55%);
  pointer-events: none;
}
.auth-content { position: relative; width: 100%; max-width: 400px; z-index: 1; }
.brand { text-align: center; color: white; margin-bottom: 28px; }
.logo-mark {
  font-size: 42px; margin-bottom: 6px;
  width: 64px; height: 64px; margin: 0 auto 10px;
  background: rgba(255,255,255,0.12); border-radius: 18px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px);
}
.brand h1 { font-size: 34px; font-weight: 700; }
.tagline { opacity: 0.85; font-size: 14px; margin-top: 4px; }
.auth-card {
  background: var(--white); border-radius: 24px 24px 0 0;
  padding: 26px 22px 36px; box-shadow: var(--shadow-lg);
}
.auth-tabs {
  display: flex; gap: 4px; background: var(--sand);
  padding: 4px; border-radius: 12px; margin-bottom: 22px;
}
.auth-tab {
  flex: 1; padding: 10px; border: none; background: transparent;
  border-radius: 10px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.auth-tab.active { background: white; color: var(--green-600); box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.auth-form { display: none; }
.auth-form.active { display: block; }
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12px; font-weight: 500;
  color: var(--muted); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.03em;
}
.field input {
  width: 100%; padding: 12px 14px; border: 1.5px solid var(--sand-dark);
  border-radius: 12px; background: var(--cream); color: var(--ink); outline: none;
}
.field input:focus { border-color: var(--green-500); background: white; }
.auth-hint { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }
.legal-consent { font-size: 12px; color: var(--muted); line-height: 1.45; margin: 12px 0 4px; text-align: center; }
.auth-legal { text-align: center; font-size: 12px; color: var(--muted); margin-top: 18px; }
.legal-consent a, .auth-legal a { color: var(--green-700); }

.trial-lead {
  font-size: 13px; color: var(--muted); line-height: 1.45; margin-bottom: 14px;
}
.trial-plans { display: flex; flex-direction: column; gap: 10px; }
.trial-plan {
  background: var(--cream); border: 1.5px solid var(--sand-dark);
  border-radius: 14px; padding: 12px 12px 12px;
}
.trial-plan.selected { border-color: var(--green-500); background: #f0faf3; }
.trial-plan-head {
  display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 4px;
}
.trial-plan-head strong { font-size: 16px; color: var(--ink); }
.trial-plan-price { font-size: 20px; font-weight: 700; }
.trial-plan-price span { font-size: 12px; font-weight: 500; color: var(--muted); }
.trial-plan .muted { margin-bottom: 10px; }
.trial-plan .btn { padding: 10px 16px; }
.reg-creds { margin-top: 16px; }
.trial-selected { margin-bottom: 12px; }

/* App shell */
.app {
  height: 100%; display: flex; flex-direction: column;
  max-width: 480px; margin: 0 auto; background: var(--cream); position: relative;
}
.app.hidden { display: none; }

.topbar {
  height: var(--topbar-h); display: flex; align-items: center; justify-content: space-between;
  padding: 0 14px; background: var(--white); border-bottom: 1px solid var(--sand-dark);
  position: sticky; top: 0; z-index: 20;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.logo-small {
  width: 28px; height: 28px; background: var(--green-500); color: white;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
}
.app-title { font-size: 17px; font-weight: 600; }
.topbar-right { display: flex; gap: 2px; }

.content {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + var(--safe-bottom) + 12px);
  -webkit-overflow-scrolling: touch;
}

.screen-panel {
  display: none; padding: 18px 16px; animation: fadeIn 0.22s ease;
}
.screen-panel.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-header { margin-bottom: 16px; }
.section-header h2 { font-size: 22px; margin-bottom: 2px; }
.subtitle { color: var(--muted); font-size: 13px; }
.section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin: 20px 0 12px;
}
.section-head h3 { font-size: 15px; font-weight: 600; }

/* Bottom nav */
.bottom-nav {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: calc(var(--nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--white); border-top: 1px solid var(--sand-dark);
  display: flex; justify-content: space-around; align-items: center; z-index: 30;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: none; border: none; color: var(--muted);
  font-size: 10px; font-weight: 500; padding: 8px 2px; cursor: pointer;
}
.nav-item.active { color: var(--green-500); }
.nav-item svg { stroke-width: 1.8; }
.nav-item.active svg { stroke-width: 2.2; }

/* Home */
.welcome { margin-bottom: 16px; }
.welcome h2 { font-size: 24px; }

.nature-scene-card {
  background: linear-gradient(145deg, var(--green-800), var(--green-600));
  color: white; border-radius: var(--radius); padding: 18px;
  margin-bottom: 16px; cursor: pointer; box-shadow: var(--shadow);
}
.ns-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px; font-size: 12px; opacity: 0.85;
}
.ns-label {
  background: rgba(255,255,255,0.15); padding: 3px 8px;
  border-radius: 6px; font-weight: 600; letter-spacing: 0.03em;
}
.nature-scene-card h3 { font-size: 18px; margin-bottom: 6px; }
.ns-excerpt {
  font-size: 14px; line-height: 1.45; opacity: 0.9;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 10px;
}
.ns-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.ns-tag {
  background: rgba(255,255,255,0.15); font-size: 11px; font-weight: 500;
  padding: 3px 8px; border-radius: 6px;
}
.ns-cta { font-size: 13px; font-weight: 600; opacity: 0.95; }
.ns-card-actions { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.ns-cta-btn {
  background: none; border: 0; color: inherit; padding: 0; cursor: pointer;
  font-size: 13px; font-weight: 600; opacity: 0.95; text-align: left;
}
.ns-cta-btn:focus { outline: 2px solid rgba(255,255,255,0.6); outline-offset: 2px; }
.ns-tags { cursor: pointer; }

/* Network / Sync bar */
.network-bar {
  background: white; border-radius: var(--radius-sm); padding: 12px 14px;
  box-shadow: var(--shadow); margin-bottom: 14px;
  display: flex; align-items: center; gap: 12px;
}
.net-label {
  font-size: 11px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.04em; flex-shrink: 0;
}
.net-sites { display: flex; flex-wrap: wrap; gap: 8px; flex: 1; }
.net-pill {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 500; padding: 4px 10px;
  border-radius: 20px; background: var(--sand);
}
.net-pill .dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.dot.online { background: #22c55e; box-shadow: 0 0 0 2px rgba(34,197,94,0.25); }
.dot.syncing { background: #3b82f6; animation: pulseDot 1.2s infinite; }
.dot.degraded { background: #f59e0b; }
.dot.offline { background: #94a3b8; }
@keyframes pulseDot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.sync-legend {
  display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px;
  font-size: 11px; color: var(--muted);
}
.sync-legend span { display: flex; align-items: center; gap: 5px; }
.sync-legend .dot {
  width: 7px; height: 7px; border-radius: 50%; display: inline-block;
}

/* Cross-site timeline */
.timeline {
  display: flex; flex-direction: column; gap: 0;
  background: white; border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 4px 0; margin-bottom: 8px; overflow: hidden;
}
.tl-item {
  display: flex; gap: 12px; padding: 10px 14px;
  border-bottom: 1px solid var(--sand);
  cursor: pointer;
}
.tl-item:last-child { border-bottom: none; }
.tl-rail {
  display: flex; flex-direction: column; align-items: center; width: 12px; flex-shrink: 0;
}
.tl-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--green-500);
  margin-top: 4px; flex-shrink: 0;
}
.tl-dot.anomaly { background: var(--alert); }
.tl-line {
  flex: 1; width: 2px; background: var(--sand-dark); margin-top: 4px; min-height: 12px;
}
.tl-body { flex: 1; min-width: 0; }
.tl-body h4 { font-size: 13px; font-weight: 600; margin-bottom: 2px; }
.tl-meta { font-size: 11px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tl-site-tag {
  background: var(--sand); color: var(--green-700);
  padding: 1px 6px; border-radius: 4px; font-weight: 500;
}
.tl-time { font-size: 11px; color: var(--muted); flex-shrink: 0; padding-top: 2px; }

.stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 4px;
}
.stat-card {
  background: white; border-radius: var(--radius-sm); padding: 14px 10px;
  text-align: center; box-shadow: var(--shadow);
}
.stat-val { display: block; font-size: 22px; font-weight: 700; color: var(--green-600); }
.stat-label { font-size: 11px; color: var(--muted); margin-top: 2px; display: block; }
.alert-stat .stat-val { color: var(--alert); }

.activity-list { display: flex; flex-direction: column; gap: 8px; }
.activity-item {
  background: white; border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
  cursor: pointer;
}
.act-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: var(--sand); display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.act-info { flex: 1; min-width: 0; }
.act-info h4 { font-size: 14px; font-weight: 600; margin-bottom: 2px; }
.act-info p { font-size: 12px; color: var(--muted); }
.act-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* Sites / Cameras */
.sites-list { display: flex; flex-direction: column; gap: 12px; }
.site-card {
  background: white; border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer;
}
.site-thumb {
  height: 120px; background: linear-gradient(160deg, #1a3a28, #2E8B4A);
  display: flex; align-items: center; justify-content: center;
  position: relative; font-size: 36px;
}
.site-thumb .live-dot {
  position: absolute; top: 10px; right: 10px;
  width: 9px; height: 9px; background: #ef4444; border-radius: 50%;
  box-shadow: 0 0 0 3px rgba(239,68,68,0.3); animation: pulse 1.5s infinite;
}
.site-thumb .sync-badge {
  position: absolute; top: 10px; left: 10px;
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 3px 8px; border-radius: 6px; letter-spacing: 0.03em;
  background: rgba(0,0,0,0.45); color: white; backdrop-filter: blur(4px);
}
.site-thumb .sync-badge.online { background: rgba(34,197,94,0.85); }
.site-thumb .sync-badge.syncing { background: rgba(59,130,246,0.85); }
.site-thumb .sync-badge.degraded { background: rgba(245,158,11,0.9); }
.site-thumb .sync-badge.offline { background: rgba(100,116,139,0.85); }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0.08); }
}
.site-body { padding: 12px 14px; }
.site-body h4 { font-size: 15px; margin-bottom: 2px; }
.site-meta { font-size: 12px; color: var(--muted); }
.site-sync-row {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px;
  font-size: 11px; color: var(--muted);
}
.site-sync-row span { display: flex; align-items: center; gap: 4px; }
.site-tags { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }
.site-tag {
  font-size: 11px; background: var(--sand); color: var(--green-700);
  padding: 2px 8px; border-radius: 6px; font-weight: 500;
}

.camera-player {
  position: fixed; inset: 0; background: #0d2818; z-index: 50;
  display: flex; flex-direction: column; max-width: 480px; margin: 0 auto;
}
.player-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px; color: white;
}
.btn-back {
  background: rgba(255,255,255,0.12); border: none; color: white;
  padding: 8px 12px; border-radius: 10px; font-weight: 500; cursor: pointer;
}
.player-frame {
  flex: 1; margin: 0 16px; background: #000; border-radius: 14px;
  position: relative; display: flex; align-items: center; justify-content: center;
  min-height: 220px; overflow: hidden;
}
.live-badge {
  position: absolute; top: 12px; left: 12px;
  background: #ef4444; color: white; font-size: 11px; font-weight: 700;
  padding: 4px 9px; border-radius: 6px; letter-spacing: 0.04em;
}
.player-placeholder { text-align: center; color: rgba(255,255,255,0.7); }
.pulse-ring {
  width: 44px; height: 44px; border: 3px solid var(--green-500);
  border-radius: 50%; margin: 0 auto 14px; animation: ringPulse 1.4s ease infinite;
}
@keyframes ringPulse {
  0% { transform: scale(0.9); opacity: 1; }
  100% { transform: scale(1.35); opacity: 0; }
}
.player-detections {
  padding: 14px 16px; max-height: 160px; overflow-y: auto;
}
.player-detections .det-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85); font-size: 13px;
}
.player-detections .det-row:last-child { border-bottom: none; }

/* Detections */
.search-bar { margin-bottom: 12px; }
.search-bar input {
  width: 100%; padding: 11px 14px; border: 1.5px solid var(--sand-dark);
  border-radius: 12px; background: white; outline: none;
}
.search-bar input:focus { border-color: var(--green-500); }
.filter-chips {
  display: flex; gap: 8px; overflow-x: auto; margin-bottom: 14px;
  padding-bottom: 4px; scrollbar-width: none;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0; padding: 6px 13px; border-radius: 20px;
  border: 1.5px solid var(--sand-dark); background: white;
  font-size: 12px; font-weight: 500; color: var(--muted); cursor: pointer;
}
.chip.active { background: var(--green-500); border-color: var(--green-500); color: white; }

.detection-list { display: flex; flex-direction: column; gap: 8px; }
.det-card {
  background: white; border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; box-shadow: var(--shadow);
}
.det-icon {
  width: 42px; height: 42px; border-radius: 10px; background: var(--sand);
  display: flex; align-items: center; justify-content: center; font-size: 18px; flex-shrink: 0;
}
.det-body { flex: 1; min-width: 0; }
.det-body h4 { font-size: 14px; font-weight: 600; }
.det-body p { font-size: 12px; color: var(--muted); }
.det-conf {
  font-size: 11px; font-weight: 600; color: var(--green-600);
  background: #d1fae5; padding: 3px 8px; border-radius: 6px;
}
.det-conf.untagged { color: var(--muted); background: var(--sand); }

/* Alerts */
.alert-list { display: flex; flex-direction: column; gap: 10px; }
.alert-card {
  background: white; border-radius: var(--radius); padding: 14px 16px;
  box-shadow: var(--shadow); border-left: 4px solid var(--alert);
}
.alert-card.resolved { border-left-color: var(--muted); opacity: 0.75; }
.alert-card.warn { border-left-color: var(--warn); }
.alert-top {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 6px;
}
.alert-top h4 { font-size: 14px; font-weight: 600; }
.alert-status {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  padding: 2px 7px; border-radius: 5px; letter-spacing: 0.03em;
}
.alert-status.open { background: var(--alert-bg); color: var(--alert); }
.alert-status.resolved { background: var(--sand); color: var(--muted); }
.alert-card p { font-size: 13px; color: var(--muted); line-height: 1.4; }
.alert-meta { font-size: 11px; color: var(--muted); margin-top: 8px; }

/* Nature Scene list */
.nature-list { display: flex; flex-direction: column; gap: 12px; }
.nature-card {
  background: white; border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.nature-card .ns-date {
  font-size: 11px; font-weight: 600; color: var(--green-600);
  text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 4px;
}
.nature-card h4 { font-size: 16px; margin-bottom: 6px; }
.nature-card .ns-story {
  font-size: 13px; color: var(--muted); line-height: 1.45;
  white-space: pre-wrap;
}
.nature-card .ns-species {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px;
}
.nature-card .ns-species span {
  font-size: 11px; background: var(--sand); color: var(--green-700);
  padding: 2px 8px; border-radius: 6px; font-weight: 500;
}
.ns-events { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
.ns-event {
  display: flex; align-items: center; gap: 8px;
  width: 100%; text-align: left;
  background: var(--sand); border: 0; border-radius: 8px;
  padding: 8px 10px; cursor: pointer; font: inherit; color: inherit;
}
.ns-event:focus { outline: 2px solid var(--green-500); outline-offset: 1px; }
.ns-event-time { font-size: 12px; font-weight: 600; color: var(--green-700); flex-shrink: 0; }
.ns-event-sp { font-size: 13px; flex: 1; }
.ns-event-thumb {
  width: 44px; height: 44px; object-fit: cover; border-radius: 6px; flex-shrink: 0;
}
.ns-event-none { font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* Gallery */
.gallery-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
}
.gal-item {
  background: white; border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer;
}
.gal-thumb {
  height: auto; aspect-ratio: 4 / 3; overflow: hidden; background: linear-gradient(145deg, #1f5c32, #3daa5c);
  display: flex; align-items: center; justify-content: center; font-size: 32px;
  position: relative;
}
.gal-thumb .gal-species {
  position: absolute; bottom: 6px; left: 6px;
  background: rgba(0,0,0,0.5); color: white; font-size: 10px;
  font-weight: 600; padding: 2px 7px; border-radius: 5px;
}
.gal-thumb.has-photo { background: #1a2a1f; }
.gal-thumb img, .det-icon img, .act-icon img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center;
}
.gal-thumb .gal-species { z-index: 1; }
.cam-strip {
  position: absolute; top: 0; left: 0; right: 0; z-index: 1;
  display: flex; justify-content: space-between; gap: 6px;
  padding: 2px 6px; background: rgba(0,0,0,0.45); color: rgba(255,255,255,0.85);
  font: 600 9px/1.3 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em; pointer-events: none; white-space: nowrap; overflow: hidden;
}
.det-icon.has-photo, .act-icon.has-photo { position: relative; overflow: hidden; background: #1a2a1f; }
.det-icon.has-photo { width: 76px; height: 57px; border-radius: 8px; }
.det-icon.has-photo .cam-strip { font-size: 7px; padding: 1px 3px; }
.det-icon.has-photo .cam-strip span:last-child { display: none; }
.gal-info { padding: 8px 10px; }
.gal-info p { font-size: 11px; color: var(--muted); }

/* Account */
.account-card {
  background: white; border-radius: var(--radius); padding: 18px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.account-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: linear-gradient(135deg, var(--green-500), var(--green-700));
  color: white; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px; flex-shrink: 0;
}
.account-info h3 { font-size: 17px; margin-bottom: 2px; }
.account-info p { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.badge {
  display: inline-block; font-size: 11px; font-weight: 600;
  padding: 3px 9px; border-radius: 20px;
}
.badge-active { background: #d1fae5; color: #065f46; }

.plan-card {
  background: white; border-radius: var(--radius); padding: 18px;
  box-shadow: var(--shadow); border: 2px solid var(--green-500); margin-bottom: 16px;
}
.plan-header {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.plan-name { font-size: 18px; font-weight: 700; color: var(--green-600); }
.plan-price { font-size: 26px; font-weight: 700; }
.plan-price span { font-size: 13px; font-weight: 500; color: var(--muted); }
.plan-features { list-style: none; margin-bottom: 12px; }
.plan-features li { font-size: 13px; padding: 4px 0; }
.plan-meta {
  background: var(--sand); border-radius: 9px; padding: 10px 12px;
  font-size: 12px; color: var(--muted);
}
.plan-meta p + p { margin-top: 3px; }

.plans-compare h4 { font-size: 14px; margin-bottom: 10px; color: var(--muted); }
.mini-plan {
  background: white; border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: var(--shadow); margin-bottom: 8px;
}
.legal-links {
  margin-top: 16px; text-align: center; font-size: 13px; color: var(--muted);
}
.legal-links a { color: var(--green-700); text-decoration: none; }
.mini-plan strong { display: block; font-size: 14px; }
.mini-plan .muted { font-size: 12px; }
.mini-plan { gap: 10px; }
.mini-plan > div { min-width: 0; }
.mini-plan .btn { flex-shrink: 0; }
.mini-plan.current { box-shadow: inset 0 0 0 1.5px var(--green-500), var(--shadow); }
.mini-plan .btn[disabled] { opacity: 0.65; cursor: default; }
.plan-card .plan-header { margin-bottom: 4px; }
.plan-blurb { margin-bottom: 12px; }

/* Clock sync */
.clock-list { display: flex; flex-direction: column; gap: 12px; }
.clock-card {
  background: white; border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.clock-card h4 { font-size: 16px; margin-bottom: 4px; }
.clock-source { font-size: 12px; color: var(--muted); margin-bottom: 12px; }
.clock-metrics {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
}
.clock-metric {
  background: var(--sand); border-radius: 10px; padding: 10px;
}
.clock-metric .k { font-size: 11px; color: var(--muted); display: block; }
.clock-metric .v { font-size: 16px; font-weight: 700; color: var(--green-700); }
.clock-metric .v.warn { color: var(--warn); }
.clock-metric .v.bad { color: var(--alert); }
.clock-demo {
  margin-top: 12px; background: white; border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow); font-size: 13px; line-height: 1.5;
}
.clock-demo strong { display: block; margin-top: 8px; font-size: 12px; color: var(--green-700); }

.add-cam { background: var(--cream); padding-bottom: 24px; }
.add-cam-head { margin-bottom: 12px; }
.wiz-q { font-weight: 650; margin: 8px 0 12px; }
.wiz-choices { display: flex; flex-direction: column; gap: 8px; }
.wiz-choice {
  text-align: left; border: 1px solid var(--sand-dark); background: #fff;
  border-radius: var(--radius-sm); padding: 12px 14px; cursor: pointer;
}
.wiz-choice:hover { border-color: var(--green-500); }
.wiz-choice strong { display: block; font-size: 14px; }
.wiz-choice span { font-size: 12px; color: var(--muted); }
.text-input {
  width: 100%; border: 1px solid var(--sand-dark); border-radius: 10px;
  padding: 10px 12px; font: inherit; margin-bottom: 8px;
}
.field-label { display: block; font-size: 12px; color: var(--muted); margin: 8px 0 4px; }

.cam-setup-bar {
  display: flex; align-items: stretch; gap: 8px;
  margin: 4px 0 14px;
}
.cam-setup-bar .btn { flex: 1; }
.help-q-btn {
  flex-shrink: 0; width: 44px; min-height: 44px;
  border-radius: 12px; border: 1.5px solid var(--green-500);
  background: #fff; color: var(--green-700);
  font-weight: 700; font-size: 18px; cursor: pointer;
}
.help-q-btn:active { transform: scale(0.98); }
.cam-select {
  width: 100%;
  min-height: 46px;
  appearance: auto;
  -webkit-appearance: menulist;
  background: #fff;
  margin-bottom: 4px;
}
.cam-select:disabled {
  background: var(--sand);
  color: var(--muted);
  opacity: 1;
}
.cam-guide { padding-bottom: 16px; }
.cam-guide-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px;
}
.cam-guide-head h3 { flex: 1; font-size: 18px; }
.guide-block {
  background: #fff; border-radius: var(--radius-sm);
  padding: 12px 14px; margin-bottom: 10px;
  box-shadow: var(--shadow);
}
.guide-block h4 { font-size: 14px; margin-bottom: 6px; color: var(--green-700); }
.guide-block p, .guide-block li { font-size: 13px; color: var(--ink); line-height: 1.45; }
.guide-steps { padding-left: 18px; }
.guide-steps li { margin: 6px 0; }
.guide-blocked { border-left: 4px solid var(--warn); }
.guide-blocked ul { padding-left: 18px; }
.wiz-choice-off {
  cursor: not-allowed; opacity: 0.78;
  border-style: dashed; background: var(--sand);
}
.wiz-choice-off:hover { border-color: var(--sand-dark); }

.inbox-card {
  margin: 12px 0; padding: 12px 14px; background: #fff; border-radius: var(--radius-sm);
  border: 1px dashed var(--green-500); font-size: 13px; line-height: 1.45;
}
.inbox-addr {
  font-family: ui-monospace, monospace; font-size: 13px; word-break: break-all;
  background: var(--sand); padding: 8px 10px; border-radius: 8px; margin: 8px 0;
}
.player-shot { width: 100%; max-height: 220px; object-fit: cover; border-radius: 8px; }

/* Desktop frame */
@media (min-width: 481px) {
  body {
    background: #e6e0d4;
    display: flex; align-items: center; justify-content: center;
  }
  .app {
    height: 90vh; max-height: 900px; border-radius: 24px;
    overflow: hidden; box-shadow: 0 20px 60px rgba(13,40,24,0.14);
  }
  #screen-auth { display: flex; align-items: center; justify-content: center; }
  .auth-bg {
    max-width: 400px; max-height: 760px; border-radius: 28px; overflow: hidden;
  }
}

/* Photo lightbox — reused by digest, gallery, home */
.lightbox {
  position: fixed; inset: 0; z-index: 5000;
  background: rgba(0, 0, 0, 0.94);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 56px 16px 28px;
}
.lightbox.hidden { display: none !important; }
.lightbox-img {
  max-width: 100%;
  max-height: calc(100dvh - 120px);
  object-fit: contain;
  border-radius: 4px;
}
.lightbox-close {
  position: absolute; top: 12px; right: 12px;
  background: rgba(255,255,255,0.12); color: #fff;
  border: 0; border-radius: 8px; padding: 8px 14px;
  font-size: 14px; font-weight: 600; cursor: pointer;
}
.lightbox-caption {
  color: #fff; margin-top: 12px; font-size: 13px; text-align: center;
  max-width: 36rem;
}
.lightbox-empty {
  color: #e6e0d4; font-size: 15px; text-align: center;
  max-width: 22rem; line-height: 1.45; padding: 0 12px;
}


/* Camera map — Esri World Topo tiles, CONUS empty default */
.screen-panel.map-panel.active {
  display: flex;
  flex-direction: column;
  padding: 12px 12px 8px;
}
.map-toolbar {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin-bottom: 8px;
}
.map-toolbar h2 { font-size: 20px; }
.sites-map {
  width: 100%;
  height: 52vh;
  min-height: 280px;
  border-radius: 12px;
  overflow: hidden;
  background: #d7e3d4;
  touch-action: pan-x pan-y;
  z-index: 1;
}
.sites-map .leaflet-container {
  width: 100%; height: 100%;
  font-family: inherit;
  z-index: 1;
}
.map-attrib {
  font-size: 11px; color: var(--muted); margin: 6px 0 8px;
}
.map-attrib a { color: inherit; }
/* Esri credits are long: keep the in-map credit to one line on phones, full text on hover/tap
   (same pattern as esri-leaflet). The full credit is also printed under the main map. */
.sites-map .leaflet-bottom.leaflet-right,
.picker-map .leaflet-bottom.leaflet-right { left: 0; }
.sites-map .leaflet-control-attribution,
.picker-map .leaflet-control-attribution {
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-sizing: border-box; cursor: pointer;
}
.sites-map .leaflet-control-attribution:hover,
.picker-map .leaflet-control-attribution:hover {
  white-space: normal;
}
.map-unlist { display: flex; flex-direction: column; gap: 8px; }
.map-miss {
  background: #fff; border-radius: var(--radius-sm); padding: 10px 12px;
  box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.map-miss p { margin-top: 2px; }
.cam-pin { background: none; border: 0; }
.cam-pin-dot {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 16px 16px 16px 4px;
  background: var(--green-500); color: #fff; font-size: 16px;
  box-shadow: 0 2px 8px rgba(13,40,24,0.28);
  transform: rotate(-45deg);
}
.cam-pin-dot { line-height: 1; }
.cam-pin-dot { transform: none; border-radius: 16px; }

.set-loc {
  margin: 10px 0 4px; padding: 10px 12px;
  background: #fff; border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}
.loc-search-row { display: flex; gap: 8px; align-items: flex-start; }
.loc-search-row .text-input { flex: 1; margin-bottom: 4px; }
.loc-search-row .btn { margin-top: 0; flex-shrink: 0; }
.loc-ll-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.picker-map {
  width: 100%; height: 180px; min-height: 160px;
  border-radius: 10px; overflow: hidden;
  background: #d7e3d4; margin: 6px 0 8px;
  touch-action: pan-x pan-y;
}
.picker-map-lg { height: 240px; min-height: 200px; }
.picker-map .leaflet-container { width: 100%; height: 100%; font-family: inherit; }
.site-tag-btn {
  border: 1px dashed var(--green-500); background: #fff;
  color: var(--green-700); cursor: pointer; font: inherit;
}
.loc-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(13,40,24,0.45);
  display: flex; align-items: flex-end; justify-content: center;
}
.loc-overlay.hidden { display: none !important; }
.loc-sheet {
  width: 100%; max-width: 480px; max-height: 92dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--cream); border-radius: 18px 18px 0 0;
  padding: 16px 16px calc(18px + var(--safe-bottom));
}
.nav-item { font-size: 9px; }

.cam-chosen-label { margin: 8px 0 4px; min-height: 1.2em; }
#cam-continue { margin-top: 10px; }
#cam-continue:disabled { opacity: 0.55; cursor: not-allowed; }
.map-pop-thumb {
  display: block; width: 120px; height: 80px; object-fit: cover;
  border-radius: 8px; margin: 6px 0 8px; background: #12261a;
}

/* ========== Email-in (js/email-in.js) ========== */
.email-addr {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 16px; font-weight: 600;
  word-break: break-all; text-align: center; color: var(--green-800);
  background: var(--sand); border: 1.5px dashed var(--green-400);
  padding: 12px 10px; border-radius: var(--radius-sm); margin: 10px 0 8px;
}
.email-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.email-flash { min-height: 1.2em; margin: 4px 0; color: var(--green-600); }
.email-tips { background: var(--cream); border-radius: var(--radius-sm); padding: 10px 12px; margin: 6px 0 12px; }
.email-tips-method { font-weight: 600; font-size: 13px; color: var(--green-700); margin-bottom: 4px; }
.email-tips ol { padding-left: 18px; margin: 6px 0; font-size: 13px; line-height: 1.45; }
.email-tips li { margin: 3px 0; }
.email-tips p { margin: 4px 0; }
.email-error { color: var(--alert); background: var(--alert-bg); border-radius: 8px; padding: 8px 10px; margin: 8px 0; font-size: 13px; }
.email-site-card .btn-block { margin-top: 8px; }
.email-status { margin: 6px 0 0; }
.email-tips-box { margin-top: 10px; }
.email-tips-box summary { cursor: pointer; font-weight: 600; font-size: 13px; color: var(--green-600); padding: 4px 0; }
.email-stop { border-color: var(--muted); color: var(--muted); }
.email-sep { border: 0; border-top: 1px solid var(--sand-dark); margin: 14px 0; }

/* ---------- Add camera by email: guided wizard ---------- */
.add-cam .btn-back { background: var(--sand); color: var(--green-700); }
.email-wiz { padding-bottom: 8px; scroll-margin-top: 12px; }
.ew-progress { height: 6px; background: var(--sand-dark); border-radius: 999px; overflow: hidden; margin: 8px 0 6px; }
.ew-progress-fill { height: 100%; width: 25%; background: var(--green-500); border-radius: 999px; transition: width .25s ease; }
.ew-steps { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; list-style: none; padding: 0; margin: 0 0 4px; font-size: 11px; color: var(--muted); }
.ew-steps li { text-align: center; }
.ew-steps li.current { color: var(--green-700); font-weight: 650; }
.ew-steps li.done { color: var(--green-600); }
.ew-steps li.done::before { content: '✓ '; }
.ew-brand { position: relative; padding-right: 40px; }
.ew-brand.selected { border-color: var(--green-500); background: #eef7f0; box-shadow: inset 0 0 0 1px var(--green-500); }
.ew-brand.selected::after { content: '✓'; position: absolute; right: 14px; top: 50%; transform: translateY(-50%); color: var(--green-600); font-weight: 700; }
.ew-loc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 8px 0 4px; }
.ew-pin { font-size: 13px; color: var(--muted); background: var(--white); border: 1px dashed var(--sand-dark); border-radius: var(--radius-sm); padding: 8px 10px; margin: 6px 0; }
.ew-pin.set { color: var(--green-700); border-color: var(--green-500); border-style: solid; }
.ew-nav { position: sticky; bottom: calc(var(--nav-h) + var(--safe-bottom)); display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; padding: 10px 0 12px; margin-top: 12px; background: var(--cream); border-top: 1px solid var(--sand-dark); z-index: 5; }
.ew-nav .btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- QA pass (Oct 6): scrollable site panel, bulk upload, per-photo IDs ---------- */
/* The site panel is position:fixed; without overflow the upload / tag controls below the
   fold could not be reached on a phone. */
.camera-player { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 140px; }
.camera-player .player-frame { flex: none; height: 240px; }
.camera-player .player-frame .player-shot { max-height: 240px; height: 100%; object-fit: contain; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.upload-btn { display: flex; align-items: center; justify-content: center; cursor: pointer; margin: 6px 0; }
.upload-btn:focus-within { outline: 2px solid var(--green-700); outline-offset: 2px; }
.btn-link { background: none; border: 0; color: var(--green-600); font-weight: 600; padding: 8px 0; cursor: pointer; text-decoration: underline; }
.desktop-only { display: none; }
@media (hover: hover) and (pointer: fine) { .desktop-only { display: inline; } }

.site-photos { margin-top: 6px; }
.pq-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin: 10px 0 6px; flex-wrap: wrap; }
.pq-bulk { margin: 0 0 8px; }
.pq-errline { background: #fff7ed; border: 1px solid #fed7aa; border-radius: 8px; padding: 8px 10px; margin: 6px 0; font-size: 12.5px; }
.pq-errline .btn { margin-top: 6px; }
.pq-row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--sand-dark, #e8e2d6); align-items: flex-start; }
.pq-thumb { flex: none; width: 76px; height: 57px; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: #000; cursor: zoom-in; }
.pq-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pq-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pq-body .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pq-st { font-weight: 600; font-size: 13.5px; }
.pq-ok { color: var(--green-700); }
.pq-review { color: #9a3412; }
.pq-err { color: #b91c1c; }
.pq-wait { color: var(--muted, #6b7280); font-weight: 500; }
.pq-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.pq-chips { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 0 8px 86px; }
.pq-chips .site-tag { border: 1px solid var(--sand-dark, #e8e2d6); cursor: pointer; padding: 4px 8px; }

.upload-progress { position: fixed; left: 50%; transform: translateX(-50%); width: calc(100% - 24px); max-width: 456px;
  bottom: calc(var(--nav-h, 64px) + env(safe-area-inset-bottom, 0px) + 10px); z-index: 60;
  background: #0d2818; color: #fff; border-radius: 12px; padding: 10px 12px 10px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.28);
  display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; font-size: 13.5px; }
.upload-progress.hidden { display: none; }
.upload-progress .up-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.upload-progress .up-sub { opacity: .8; font-size: 12px; }
.upload-progress .up-track { grid-column: 1 / -1; height: 5px; background: rgba(255,255,255,.18); border-radius: 999px; overflow: hidden; order: 3; }
.upload-progress .up-fill { height: 100%; width: 0; background: #3daa5c; transition: width .3s ease; }
.upload-progress .up-btns { display: flex; align-items: flex-start; gap: 6px; }
.upload-progress .up-btns .btn { color: #fff; border-color: rgba(255,255,255,.6); padding: 4px 10px; }
.upload-progress .up-close { background: none; border: 0; color: #fff; font-size: 22px; line-height: 1; cursor: pointer; padding: 0 2px; }
.drop-overlay { position: fixed; inset: 0; z-index: 70; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px;
  background: rgba(46,139,74,.88); color: #fff; font: 600 20px/1.3 Inter, system-ui, sans-serif; border: 4px dashed #fff; pointer-events: none; }
.drop-overlay.drop-nosite { background: rgba(60,60,60,.85); }
.drop-overlay.hidden { display: none; }
.cap-banner { border-radius: 10px; padding: 10px 12px; margin: 8px 0; font-size: 13.5px; font-weight: 600; line-height: 1.4; }
.cap-yes { background: #eaf6ee; color: var(--green-700); border: 1px solid #bfe3ca; }
.cap-no { background: #fff7ed; color: #9a3412; border: 1px solid #fed7aa; }
.cap-note { margin: 0 0 8px; }
.wiz-choice-main { border-color: var(--green-500) !important; box-shadow: inset 0 0 0 1px var(--green-500); background: #f3faf5; }
.wiz-choice[disabled] { opacity: .55; cursor: not-allowed; }
.email-auto-note { margin: 6px 0 0; }
