:root {
  --ink: #14181d;
  --muted: #5d6872;
  --line: rgba(20, 24, 29, 0.08);
  --bg: #e8eef1;
  --panel: #ffffff;
  --teal: #0f5f5a;
  --teal-2: #14756e;
  --mist: #e8f4f2;
  --gold: #c4a15a;
  --shadow: 0 14px 36px rgba(20, 24, 29, 0.1);
  --u1: #5c6b7a;
  --u2: #1d6a8a;
  --u3: #c47a1a;
  --u4: #b42318;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tab-h: 68px;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: Manrope, sans-serif;
  background: #0d1216;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

.app {
  width: min(480px, 100%);
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(var(--tab-h) + var(--safe-bottom) + 8px);
  position: relative;
  background:
    radial-gradient(700px 280px at 10% -10%, rgba(15, 95, 90, 0.18), transparent 55%),
    radial-gradient(560px 240px at 100% 0%, rgba(196, 161, 90, 0.12), transparent 50%),
    #e8eef1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 10px;
  backdrop-filter: blur(14px);
  background: rgba(232, 238, 241, 0.88);
}
.brand { display: flex; gap: 10px; align-items: center; }
.eyebrow {
  margin: 0;
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 800;
  color: var(--teal);
}
h1 {
  margin: 0;
  font-family: Outfit, Manrope, sans-serif;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1;
}
.role-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: var(--shadow);
}

.screens { padding: 0 16px 18px; }
#screen-report.screen { padding: 0; margin: 0 -16px; }
.screen { display: none; animation: rise 0.35s ease both; }
.screen.active { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Live detect camera */
.detect-stage {
  position: relative;
  height: calc(100dvh - 132px - var(--safe-bottom));
  min-height: 420px;
  overflow: hidden;
  background: #101418;
  color: #fff;
}
.detect-stage.has-result .scan-grid,
.detect-stage.has-result .focus-frame,
.detect-stage.has-result .detect-status {
  opacity: 0.35;
}
.detect-stage video,
.detect-stage #freezeFrame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.detect-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  background: linear-gradient(160deg, #1a242b, #0f5f5a 140%);
}
.detect-fallback p { margin: 0 0 8px; font-weight: 700; }
.scan-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
  background-size: 42px 42px;
  opacity: 0.35;
  pointer-events: none;
}
.focus-frame {
  position: absolute;
  left: 50%;
  top: 42%;
  width: min(62vw, 260px);
  height: min(62vw, 260px);
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.corner {
  position: absolute;
  width: 28px;
  height: 28px;
  border: 3px solid #fff;
}
.corner.tl { left: 0; top: 0; border-right: 0; border-bottom: 0; }
.corner.tr { right: 0; top: 0; border-left: 0; border-bottom: 0; }
.corner.bl { left: 0; bottom: 0; border-right: 0; border-top: 0; }
.corner.br { right: 0; bottom: 0; border-left: 0; border-top: 0; }
.focus-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.9);
  box-shadow: 0 0 0 8px rgba(255,255,255,0.15);
}
.scan-line {
  position: absolute;
  left: 18%;
  right: 18%;
  top: 18%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #e7c98a, transparent);
  box-shadow: 0 0 18px rgba(231, 201, 138, 0.8);
  animation: scan 1.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes scan {
  0% { top: 18%; opacity: 0.2; }
  50% { opacity: 1; }
  100% { top: 70%; opacity: 0.2; }
}
.detect-status {
  position: absolute;
  left: 0;
  right: 0;
  top: 18px;
  margin: 0;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-shadow: 0 2px 12px rgba(0,0,0,0.45);
}

.glass-card {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  top: auto;
  max-height: min(68dvh, calc(100% - 24px));
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  padding: 12px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(18px);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
  color: var(--ink);
  animation: rise 0.3s ease;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  z-index: 8;
  overscroll-behavior: contain;
}
.glass-thumb {
  width: 64px;
  height: 64px;
  border-radius: 14px;
  overflow: hidden;
  background: #d8e2e5;
  flex: none;
}
.glass-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.glass-copy {
  min-width: 0;
  display: grid;
  gap: 6px;
  align-content: start;
}
.glass-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: flex-start;
}
.glass-top h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.level-wrap {
  display: grid;
  gap: 2px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  flex: none;
  max-width: 46%;
}
.level-wrap select {
  border: 0;
  background: #eef4f2;
  border-radius: 999px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink);
  max-width: 100%;
}
.glass-copy > p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.glass-level {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.glass-tip {
  margin: 0 !important;
  padding-top: 8px;
  border-top: 1px solid rgba(20, 24, 29, 0.08);
  color: var(--ink) !important;
  font-weight: 700;
}
.glass-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 8px;
  margin-top: 4px;
  position: sticky;
  bottom: 0;
  padding-top: 4px;
  background: linear-gradient(180deg, rgba(255,255,255,0), rgba(255,255,255,0.96) 30%);
}
.glass-actions .btn {
  min-height: 44px;
  padding: 12px 14px;
}
.glass-dup {
  margin-top: 2px;
}
.glass-meta {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
  word-break: break-word;
}
.redact-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  background: #eef4f2;
  border: 1px solid rgba(15, 95, 90, 0.14);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}
.redact-row input {
  margin-top: 2px;
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--teal);
}

.shutter-wrap {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 18px;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  align-items: end;
  gap: 10px;
  z-index: 5;
}
.shutter-core {
  display: grid;
  place-items: center;
  gap: 6px;
}
.shutter-wrap p {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
}
.shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,0.92);
  background: radial-gradient(circle at 50% 50%, #fff 0 58%, transparent 59%);
  box-shadow: 0 10px 28px rgba(0,0,0,0.35);
  cursor: pointer;
}
.shutter:active { transform: scale(0.96); }
.live-side-btn {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 64px;
  border: 1px solid rgba(255,255,255,0.28);
  border-radius: 16px;
  background: rgba(12, 18, 22, 0.48);
  color: #fff;
  padding: 8px 6px;
  backdrop-filter: blur(10px);
  cursor: pointer;
}
.live-side-btn svg {
  width: 22px;
  height: 22px;
}
.live-side-btn span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.detect-stage.locked .shutter-wrap { opacity: 0.35; pointer-events: none; }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 12px 16px;
  font-weight: 800;
  cursor: pointer;
}
.btn.primary {
  background: linear-gradient(160deg, #14756e, #0f5f5a);
  color: #f7f4ee;
  box-shadow: 0 10px 24px rgba(15, 95, 90, 0.28);
}
.btn.ghost {
  background: #eef3f4;
  color: var(--ink);
}
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.fineprint {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
  text-align: center;
}

.urgency-pill, .pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
}
.u1 { background: var(--u1); }
.u2 { background: var(--u2); }
.u3 { background: var(--u3); }
.u4 { background: var(--u4); }

.dup-banner {
  border-radius: 14px;
  padding: 10px 12px;
  background: #fff6e8;
  border: 1px solid rgba(196, 122, 26, 0.28);
}
.dup-banner strong { display: block; margin-bottom: 4px; font-size: 12px; }
.dup-banner p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.4; }

.queue-top {
  display: grid;
  gap: 12px;
  margin-bottom: 14px;
}
.queue-actions {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 8px;
}
.queue-actions:has(> :only-child) {
  grid-template-columns: 1fr;
}
.action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  text-align: center;
}
.action-primary {
  background: linear-gradient(160deg, #14756e, #0f5f5a);
  color: #f4fbfa;
  box-shadow: 0 10px 22px rgba(15, 95, 90, 0.24);
}
.action-ghost {
  background: #fff;
  color: var(--teal);
  border-color: rgba(15, 95, 90, 0.22);
}
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.stat {
  position: relative;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 12px 8px 14px;
  box-shadow: var(--shadow);
  text-align: center;
}
.stat::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 3px;
  background: var(--teal);
}
.stat-view::before { background: var(--teal); }
.stat-urgent::before { background: var(--u4); }
.stat-review::before { background: var(--u3); }
.stat-view { background: linear-gradient(180deg, #f3faf9 0%, #fff 42%); }
.stat-urgent { background: linear-gradient(180deg, #fff4f2 0%, #fff 42%); }
.stat-review { background: linear-gradient(180deg, #fff8ef 0%, #fff 42%); }
.stat span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 4px;
}
.stat b {
  display: block;
  font-family: Outfit, Manrope, sans-serif;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
}
.stat-urgent b { color: var(--u4); }
.stat-review b { color: #9a5a10; }

.filter-block {
  display: grid;
  gap: 8px;
}
.filter-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chip-row {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 1px 0 rgba(20, 24, 29, 0.03);
}
.chip.on {
  background: var(--ink);
  color: #f7f4ee;
  border-color: var(--ink);
}

.tools {
  display: grid;
  grid-template-columns: 1fr 1.1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.class-pick { display: grid; gap: 4px; }
.class-pick span {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.class-pick select,
.tools input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: 12px 14px;
  outline: none;
}
.class-pick select {
  appearance: none;
  padding-right: 28px;
  background-image:
    linear-gradient(45deg, transparent 50%, #14181d 50%),
    linear-gradient(135deg, #14181d 50%, transparent 50%);
  background-position: calc(100% - 14px) 54%, calc(100% - 9px) 54%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.job-list { display: grid; gap: 10px; }
.job {
  width: 100%;
  display: grid;
  grid-template-columns: 84px 1fr;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 18px;
  box-shadow: var(--shadow);
  text-align: left;
  cursor: pointer;
}
.thumb, .sheet-photo .thumb {
  width: 84px;
  height: 84px;
  border-radius: 14px;
  object-fit: cover;
  background: #d8e2e5;
}
.thumb.ph {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 800;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.job h3 {
  margin: 0 0 4px;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.job .meta {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.job .tags { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.flag {
  font-size: 11px;
  font-weight: 800;
  color: var(--u4);
}
.flag.ok { color: var(--teal); }
.empty {
  padding: 36px 12px;
  text-align: center;
  color: var(--muted);
}

.map-shell {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
#map { height: calc(100dvh - 210px); min-height: 420px; background: #d5e0e4; }
.map-legend {
  display: flex;
  gap: 12px;
  padding: 10px 14px 0;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
}
.map-legend i {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 99px;
  margin-right: 5px;
}
.map-legend i.u1 { background: var(--u1); }
.map-legend i.u2 { background: var(--u2); }
.map-legend i.u3 { background: var(--u3); }
.map-legend i.u4 { background: var(--u4); }
.map-note {
  margin: 0;
  padding: 10px 14px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.tabbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding: 8px 12px calc(8px + var(--safe-bottom));
  background: rgba(255, 255, 255, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(16px);
  z-index: 30;
}
.tab {
  border: 0;
  background: transparent;
  border-radius: 16px;
  padding: 8px 6px 6px;
  color: var(--muted);
  display: grid;
  gap: 2px;
  place-items: center;
  font-size: 11px;
  font-weight: 800;
}
.tab svg { width: 22px; height: 22px; }
.tab.on {
  color: var(--teal);
  background: var(--mist);
}

.sheet { position: fixed; inset: 0; z-index: 50; }
.sheet-scrim {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(10, 14, 18, 0.45);
}
.sheet-panel {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: min(480px, 100%);
  background: #fff;
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, 0.2);
  max-height: 88dvh;
  overflow: auto;
  padding-bottom: calc(18px + var(--safe-bottom));
  animation: sheetUp 0.28s ease;
}
@keyframes sheetUp {
  from { transform: translate(-50%, 24px); opacity: 0.6; }
  to { transform: translate(-50%, 0); opacity: 1; }
}
.sheet-handle {
  width: 42px; height: 4px;
  border-radius: 99px;
  margin: 10px auto 8px;
  background: #d5dde2;
}
.sheet-photo {
  margin: 0 16px;
  border-radius: 18px;
  overflow: hidden;
  background: #d8e2e5;
  min-height: 180px;
  cursor: zoom-in;
}
.sheet-photo img, .sheet-photo .thumb {
  width: 100%;
  height: 220px;
  border-radius: 18px;
  object-fit: cover;
}
.sheet-body { padding: 14px 16px 0; }
.sheet-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}
.sheet-title-row h3 {
  margin: 0;
  font-size: 20px;
  letter-spacing: -0.02em;
}
.sheet-meta, .sheet-flag {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}
.sheet-flag.hot { color: var(--u4); font-weight: 800; }
.sheet-actions {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.sheet-actions .btn { width: 100%; }
.sheet-actions .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(10, 14, 18, 0.9);
  display: grid;
  place-items: center;
  padding: 24px 16px 40px;
}
.lightbox img {
  max-width: min(920px, 94vw);
  max-height: 78vh;
  border-radius: 16px;
  object-fit: contain;
  background: #101418;
}
.lightbox figcaption {
  margin-top: 12px;
  color: #f6f1e8;
  text-align: center;
  font-weight: 700;
}
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: 0;
  background: #f6f1e8;
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 800;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab-h) + var(--safe-bottom) + 18px);
  transform: translateX(-50%);
  z-index: 90;
  background: var(--ink);
  color: #f7f4ee;
  border-radius: 999px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow);
  width: max-content;
  max-width: calc(100% - 32px);
}

.export-btn { border: 0; }
.dup-banner .btn {
  margin-top: 8px;
}

@media (max-height: 720px) {
  .glass-card {
    max-height: min(74dvh, calc(100% - 16px));
    grid-template-columns: 56px minmax(0, 1fr);
    gap: 8px;
    padding: 10px;
  }
  .glass-thumb { width: 56px; height: 56px; }
  .glass-top h3 { font-size: 16px; }
  .glass-copy > p,
  .glass-tip { font-size: 11px; }
}

@media (max-width: 380px) {
  .glass-top { flex-direction: column; }
  .level-wrap { max-width: 100%; width: 100%; }
  .glass-actions { grid-template-columns: 1fr; }
}
