:root {
  --green: #32831c;
  --green-deep: #256314;
  --grey: #8d8787;
  --bg: #121512;
  --surface: #1c211b;
  --surface-2: #262d24;
  --text: #f3f5f2;
  --text-dim: #b9c0b6;
  --danger: #c1442e;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--green); text-decoration: none; }

/* --- top bar (home) --- */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; background: var(--green-deep); color: #fff;
  padding-top: max(12px, env(safe-area-inset-top));
}
.topbar-title { font-weight: 700; font-size: 17px; }
.topbar form { margin: 0; }
.btn-ghost {
  background: transparent; border: 1px solid rgba(255,255,255,.5);
  color: #fff; padding: 7px 12px; border-radius: 8px; font-size: 14px; cursor: pointer;
}

.screen { padding: 16px; max-width: 720px; margin: 0 auto; }

/* --- auth --- */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid #2b332a; border-radius: 16px; padding: 28px 24px;
}
.brand { text-align: center; margin-bottom: 20px; }
.brand-logo { width: 64px; height: 64px; border-radius: 50%; }
.brand-name { font-size: 26px; font-weight: 800; margin-top: 10px; letter-spacing: .5px; }
.brand-sub { color: var(--text-dim); font-size: 12px; margin-top: 2px; }
.auth-card label { display: block; font-size: 13px; color: var(--text-dim); margin-top: 14px; }
.auth-card input {
  width: 100%; margin-top: 6px; padding: 12px; font-size: 16px;
  background: var(--bg); color: var(--text);
  border: 1px solid #333c31; border-radius: 10px;
}
.auth-card input:focus { outline: none; border-color: var(--green); }
.alert {
  background: rgba(193,68,46,.15); border: 1px solid var(--danger);
  color: #f3b9ad; padding: 10px 12px; border-radius: 10px; font-size: 14px;
}

.btn-primary {
  width: 100%; margin-top: 20px; padding: 13px; font-size: 16px; font-weight: 700;
  background: var(--green); color: #fff; border: none; border-radius: 10px; cursor: pointer;
}
.btn-primary:hover { background: var(--green-deep); }
.btn-primary:disabled { opacity: .6; }

/* --- site list (home) --- */
.site-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.site-card {
  display: grid; gap: 4px; padding: 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid #2b332a; color: var(--text);
}
.site-card:active { background: var(--surface-2); }
.site-name { font-size: 18px; font-weight: 700; }
.site-addr { color: var(--text-dim); font-size: 13px; }
.site-go { color: var(--green); font-size: 13px; margin-top: 6px; }
.site-card--done {
  border-color: #2e5c1c; background: #1a2916;
}
.site-go--done { color: #4caf50; }
.site-card--pending { border-color: #5c4a1c; background: #29200a; }
.site-go--pending   { color: #ffb000; }
.site-meta { display: flex; flex-direction: column; gap: 3px; }
.site-type-badge {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-dim);
}
.empty { color: var(--text-dim); text-align: center; padding: 48px 16px; }

/* ===================================================================
   CAMERA SCREEN - full-screen, no scroll, native-camera-app layout
   =================================================================== */

html:has(.camera-screen),
body:has(.camera-screen) {
  overflow: hidden;
  height: 100%;
  overscroll-behavior: none;
  touch-action: none;
}

.camera-screen {
  position: fixed; inset: 0; background: #0a0a0b;
  display: flex; flex-direction: column; overflow: hidden;
  overscroll-behavior: none;
  --amber: #ffb000;
}

.cam-header {
  position: absolute; top: 0; left: 0; right: 0; z-index: 6;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
  color: #fff;
  background: linear-gradient(to bottom, rgba(0,0,0,.65), rgba(0,0,0,0));
}
.cam-header form { margin: 0; }
.cam-site { font-weight: 700; font-size: 16px; letter-spacing: .02em; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.cam-icon-btn {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; font-size: 18px; line-height: 1;
  background: rgba(0,0,0,.4); color: #fff; border: none; cursor: pointer; text-decoration: none;
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}

.cam-stage {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  background: #000; overflow: hidden;
  container-type: size;
}

/* viewfinder — fits both width AND height constraint via container query units */
.viewfinder {
  position: relative;
  aspect-ratio: 3 / 4;
  width: min(100cqw, 75cqh);
  background: #000; overflow: hidden;
}
#cam-video {
  width: 100%; height: 100%; object-fit: cover; display: block; background: #000;
}

/* corner framing brackets — relative to viewfinder, not the full stage */
.corners, .cv { position: absolute; inset: 0; pointer-events: none; }
.corners::before, .corners::after, .cv::before, .cv::after {
  content: ""; position: absolute; width: 22px; height: 22px;
  border: 2px solid rgba(255,255,255,.5);
}
.corners::before { top: 10px; left: 10px; border-right: 0; border-bottom: 0; border-radius: 4px 0 0 0; }
.corners::after  { top: 10px; right: 10px; border-left: 0; border-bottom: 0; border-radius: 0 4px 0 0; }
.cv::before      { bottom: 10px; left: 10px; border-right: 0; border-top: 0; border-radius: 0 0 0 4px; }
.cv::after       { bottom: 10px; right: 10px; border-left: 0; border-top: 0; border-radius: 0 0 4px 0; }

/* GPS pill — bottom-right so it doesn't conflict with the absolute header */
.gps-pill {
  position: absolute; bottom: 48px; right: 10px; z-index: 5;
  font-size: 11px; font-weight: 600; letter-spacing: .03em; color: #fff;
  background: rgba(0,0,0,.45); padding: 4px 9px; border-radius: 20px;
  display: flex; align-items: center; gap: 6px;
  font-variant-numeric: tabular-nums; pointer-events: none;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
}
.gps-pill .gdot { width: 7px; height: 7px; border-radius: 50%; background: #8c8c88; flex: none; }
.gps-pill.ok  .gdot { background: #36c46a; }
.gps-pill.err .gdot { background: #ff5d52; }
.gps-pill.wait .gdot { background: var(--amber); animation: gps-pulse 1.2s infinite; }
@keyframes gps-pulse { 50% { opacity: .3; } }

/* shutter flash */
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; z-index: 4; }
.flash.go { animation: cam-flash .28s ease-out forwards; }
@keyframes cam-flash { 0% { opacity: .85; } 100% { opacity: 0; } }

.cam-controls {
  flex: 0 0 auto; background: #0a0a0b;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: clamp(10px,2dvh,18px) 22px max(clamp(10px,2dvh,18px), env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255,255,255,.07);
}

/* ring + inner circle shutter — matches camera_app */
.shutter {
  grid-column: 2; justify-self: center;
  width: clamp(56px,9.5dvh,80px); height: clamp(56px,9.5dvh,80px); border-radius: 50%;
  background: transparent; border: 4px solid var(--amber);
  display: flex; align-items: center; justify-content: center;
  padding: 0; cursor: pointer; touch-action: manipulation;
}
.shutter .inner {
  width: clamp(42px,7dvh,60px); height: clamp(42px,7dvh,60px); border-radius: 50%; background: #fff;
  transition: transform .08s ease; pointer-events: none;
}
.shutter:active .inner { transform: scale(.86); }
.shutter:disabled { opacity: .4; }

.control-spacer { grid-column: 3; }

.gallery-btn {
  grid-column: 1; justify-self: start; position: relative;
  width: clamp(44px,7.5dvh,62px); height: clamp(44px,7.5dvh,62px); border-radius: 14px; cursor: pointer; padding: 0;
  background: #141416; border: 2px solid rgba(255,255,255,.18);
  box-shadow: 0 2px 10px rgba(0,0,0,.6);
  transition: transform .12s, box-shadow .12s;
  -webkit-tap-highlight-color: transparent;
}
.gallery-btn:active { transform: scale(.91); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
.gallery-btn::after {
  content: "\25A6"; position: absolute; inset: 0; display: grid; place-items: center;
  color: rgba(255,255,255,.4); font-size: 24px;
}
.gallery-btn.has-thumb::after { content: ""; }
#gallery-thumb { width: 100%; height: 100%; object-fit: cover; display: none; border-radius: 12px; }
.gallery-btn.has-thumb #gallery-thumb { display: block; }
.count-badge {
  position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px;
  padding: 0 5px; border-radius: 10px; background: var(--amber);
  color: #1a1200; font-size: 12px; font-weight: 700; line-height: 20px; text-align: center;
}

/* status toast — sits inside .viewfinder, so absolute positioning is relative to it */
.status {
  position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%);
  z-index: 6; max-width: 86%; white-space: nowrap; text-align: center;
  padding: 7px 14px; border-radius: 999px; font-size: 13.5px; font-weight: 600;
  background: rgba(20,20,22,.8); color: #f3f3f1;
  border: 1px solid rgba(255,255,255,.09);
  opacity: 0; transition: opacity .2s; pointer-events: none;
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.status.show { opacity: 1; }
.status.error { background: rgba(255,93,82,.85); border-color: transparent; color: #fff; }
.status.ok    { background: rgba(54,196,106,.85); border-color: transparent; color: #fff; }

/* --- capture preview / confirm --- */
.preview-overlay {
  position: fixed; inset: 0; z-index: 20; display: none;
  background: rgba(0,0,0,.94); flex-direction: column;
  padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}
.preview-overlay.show { display: flex; }
#preview-img { flex: 1; min-height: 0; width: 100%; object-fit: contain; border-radius: 12px; }
.preview-actions { display: flex; gap: 12px; margin-top: 16px; }
.preview-actions .btn-primary, .preview-actions .btn-ghost-lg { margin-top: 0; flex: 1; }
.btn-ghost-lg {
  padding: 13px; font-size: 16px; font-weight: 700; border-radius: 10px; cursor: pointer;
  background: transparent; color: var(--text); border: 1px solid var(--grey);
}

/* --- gallery sheet --- */
.sheet {
  position: fixed; inset: 0; z-index: 18; display: none;
  flex-direction: column; background: var(--bg);
  touch-action: pan-y; /* re-enable vertical scroll inside the sheet */
}
.sheet.show { display: flex; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: max(12px, env(safe-area-inset-top)) 16px 12px;
  background: var(--green-deep); color: #fff;
}
.sheet-title { font-size: 14px; font-weight: 600; }
.sheet .gallery {
  flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px;
  padding: 12px; align-content: start;
  touch-action: pan-y;
}
.sheet .gallery img {
  width: 100%; aspect-ratio: 3 / 4; object-fit: cover;
  border-radius: 8px; background: var(--surface-2); cursor: pointer;
}
.sheet .empty { display: none; }
.sheet.is-empty .gallery { display: none; }
.sheet.is-empty .empty { display: block; }

/* --- remaining count pill (camera page) --- */
.remaining-pill {
  position: absolute; top: 60px; left: 50%; transform: translateX(-50%); z-index: 5;
  font-size: 13px; font-weight: 700; color: #fff;
  background: rgba(0,0,0,.55); padding: 5px 14px; border-radius: 20px;
  pointer-events: none; white-space: nowrap;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.15);
}

/* --- product tag in camera header --- */
.cam-product-tag {
  display: inline-block; margin-left: 6px; font-size: 12px; font-weight: 600;
  background: rgba(255,255,255,.18); padding: 2px 8px; border-radius: 10px;
  vertical-align: middle;
}

/* --- task dashboard (site.html) --- */
.task-section { margin-bottom: 28px; }
.task-section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-dim); margin: 0 0 10px;
}
.task-section-note { font-weight: 400; text-transform: none; letter-spacing: 0; font-size: 11px; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }

.task-card {
  display: flex; align-items: center; gap: 12px; padding: 14px 16px;
  background: var(--surface); border: 1px solid #2b332a; border-radius: 14px;
  color: var(--text); text-decoration: none; transition: background .12s;
}
.task-card:active { background: var(--surface-2); }
.task-card--done {
  border-color: #2e5c1c; background: #1a2916;
}
.task-card--sub { margin-left: 20px; border-radius: 10px; }
.task-card--disabled { opacity: .5; cursor: default; }

.task-icon { font-size: 22px; flex: none; width: 32px; text-align: center; }
.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.task-name { font-size: 15px; font-weight: 600; }
.task-desc { font-size: 12px; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.task-progress {
  flex: none; font-size: 14px; font-weight: 700; color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.task-progress--done { color: #4caf50; }

/* --- complete section --- */
.complete-section { margin-top: 32px; padding-bottom: 32px; }
.complete-section .btn-primary { margin-top: 0; }
.complete-badge {
  text-align: center; padding: 14px; border-radius: 12px;
  background: #1a2916; border: 1px solid #2e5c1c;
  color: #4caf50; font-weight: 700; font-size: 15px;
}
.review-pending-badge {
  text-align: center; padding: 14px; border-radius: 12px;
  background: #29200a; border: 1px solid #5c4a1c;
  color: #ffb000; font-weight: 700; font-size: 15px;
}
.complete-hint {
  text-align: center; color: var(--text-dim); font-size: 13px; margin-top: 10px;
}

/* --- review queue / review task page --- */
.btn-ghost--amber { border-color: #ffb000; color: #ffb000; }

.btn-approve {
  background: var(--green); color: #fff; border: none;
  padding: 7px 14px; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer;
}
.btn-approve:disabled { opacity: .6; }
.btn-approved { color: #4caf50; font-weight: 700; font-size: 14px; }

.review-meta-bar {
  display: flex; flex-wrap: wrap; gap: 6px 14px;
  margin-bottom: 20px; padding: 12px 14px;
  background: var(--surface); border-radius: 12px;
  font-size: 13px; color: var(--text-dim);
}
.review-meta-bar span { display: flex; align-items: center; gap: 5px; }

.review-section { margin-bottom: 32px; }
.review-section-title {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--text-dim); margin: 0 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid #2b332a;
}

.review-photo-grid { display: flex; flex-direction: column; gap: 16px; }
.review-photo { margin: 0; background: var(--surface); border-radius: 14px; overflow: hidden; }
.review-photo a { display: block; }
.review-photo img {
  width: 100%; max-height: 70vh; object-fit: contain;
  background: #0d100d; display: block;
}
.review-photo-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px;
  padding: 10px 12px; font-size: 12px; color: var(--text-dim); line-height: 1.4;
}
.review-photo-meta .meta-product {
  width: 100%; font-size: 12px; color: var(--text); font-weight: 600; padding-top: 2px;
}
.gps-ok { color: #36c46a; font-weight: 600; }
.gps-no { color: #ff5d52; font-weight: 600; }

/* --- lightbox --- */
.lightbox { position: fixed; inset: 0; z-index: 22; display: none; background: rgba(0,0,0,.96); touch-action: pan-y; }
.lightbox.show {
  display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom));
}
.lightbox img { flex: 1; min-height: 0; width: 100%; object-fit: contain; }
.lightbox .btn-ghost { align-self: flex-start; margin-bottom: 8px; }
