:root {
  --bg: #05070c;
  --surface: #0e131c;
  --surface-2: #151b27;
  --ink: #eef3fb;
  --muted: #8b97ab;
  --line: rgba(255, 255, 255, 0.08);
  --accent: #5b8cff;
  --accent-soft: rgba(91, 140, 255, 0.16);
  --ok: #3ee0b4;
  --warn: #f5c14a;
  --tab: 68px;
  --font: "Manrope", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background: #020308;
}

body {
  padding: var(--safe-t) 0 0;
  overscroll-behavior: none;
}

button, input, select, textarea { font-family: inherit; color: inherit; }

.view {
  display: none;
  height: calc(100dvh - var(--tab) - var(--safe-t) - var(--safe-b));
}
.view.on { display: block; }

.camera-stage {
  position: relative;
  height: 100%;
  overflow: hidden;
  background: #000;
}

#scan-video, #reader, #reader video, #reader canvas {
  position: absolute;
  inset: 0;
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  border: 0;
}

#reader { background: transparent; }
#reader img,
#reader__dashboard_section,
#reader__status_span,
#reader__header_message,
#qr-shaded-region { display: none !important; }
#reader__scan_region {
  position: absolute !important;
  inset: 0 !important;
  border: 0 !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.scan-vignette {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse 58% 46% at 50% 36%, transparent 42%, rgba(0, 0, 0, 0.5) 100%);
}

.scan-hint {
  position: absolute;
  top: 92px;
  left: 20px;
  right: 20px;
  z-index: 3;
  margin: 0;
  text-align: center;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.85);
  pointer-events: none;
}

.scan-mask {
  position: absolute;
  top: 124px;
  left: 28px;
  right: 28px;
  bottom: 268px;
  z-index: 2;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.scan-frame {
  width: min(72vw, 280px);
  height: 118px;
  position: relative;
}

.scan-frame span {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2.5px solid rgba(255, 255, 255, 0.95);
}

.scan-frame span:nth-child(1) { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.scan-frame span:nth-child(2) { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.scan-frame span:nth-child(3) { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.scan-frame span:nth-child(4) { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }

.scan-line {
  position: absolute;
  left: 14px;
  right: 14px;
  height: 1px;
  top: 10px;
  background: linear-gradient(90deg, transparent, #7ad7ff, transparent);
  box-shadow: 0 0 10px rgba(122, 215, 255, 0.7);
  animation: scan-sweep 2.4s ease-in-out infinite;
}

@keyframes scan-sweep {
  0%, 100% { top: 10px; opacity: 0.25; }
  50% { top: calc(100% - 12px); opacity: 1; }
}

.scan-code {
  position: absolute;
  left: 50%;
  top: 52%;
  transform: translate(-50%, 52px);
  z-index: 3;
  margin: 0;
  max-width: 80%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--ok);
  background: rgba(4, 10, 16, 0.72);
  border: 1px solid rgba(62, 224, 180, 0.35);
  backdrop-filter: blur(12px);
  padding: 6px 12px;
  border-radius: 999px;
  pointer-events: none;
}

.scan-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 14px 0;
  color: #fff;
}

.brand {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.hud-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(4, 8, 16, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scan-top-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.relogio {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 7px 10px;
  border-radius: 999px;
  background: rgba(4, 8, 16, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
}

.ghost-light {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(8, 12, 20, 0.5);
  color: #fff;
  border-radius: 999px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 0.78rem;
  backdrop-filter: blur(16px);
}

.dock {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 4;
  background: rgba(12, 16, 24, 0.62);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 22px;
  padding: 12px;
}

.who {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 16px;
  padding: 11px 13px;
  text-align: left;
}

.who span {
  display: block;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.who strong {
  display: block;
  margin-top: 2px;
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 650;
}

.who.ready {
  border-color: rgba(62, 224, 180, 0.4);
  box-shadow: 0 0 0 1px rgba(62, 224, 180, 0.12);
}

.dock-selects {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.dock-selects label {
  display: grid;
  gap: 4px;
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}

.dock-selects select,
.field, .filters input, .filters select {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0 12px;
  background: var(--surface-2);
  font-size: 0.92rem;
  color: var(--ink);
}

.dock-tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.dock-tools button,
.btn-foto {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
  display: grid;
  place-items: center;
  font-size: 0.86rem;
}

.btn-foto { background: var(--accent); color: #fff; border-color: transparent; }
.btn-foto input { display: none; }

.tabbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--tab) + var(--safe-b));
  padding: 6px 8px var(--safe-b);
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  background: #070a10;
  border-top: 1px solid var(--line);
  z-index: 8;
}

.tabbar button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: grid;
  place-items: center;
  gap: 2px;
}

.tabbar svg { width: 20px; height: 20px; }
.tabbar button.on { color: var(--accent); }

.page {
  height: 100%;
  overflow: auto;
  background:
    radial-gradient(700px 240px at 80% -8%, rgba(91, 140, 255, 0.16) 0%, transparent 55%),
    var(--bg);
  padding: 18px 16px 24px;
}

.page-head { margin-bottom: 14px; }
.eyebrow {
  margin: 0 0 4px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.68rem;
  color: var(--accent);
  font-weight: 800;
}

.page h1, .sheet h2 {
  margin: 0;
  font-family: var(--display);
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.muted { color: var(--muted); margin: 6px 0 0; line-height: 1.45; }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 14px 0;
}

.stat, .card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
}

.stat b {
  display: block;
  font-family: var(--display);
  font-size: 1.7rem;
}

.stat span { color: var(--muted); font-size: 0.82rem; }

.filters {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.item {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  margin-bottom: 10px;
}

.item-pendente {
  border-color: rgba(245, 193, 74, 0.35);
  background: linear-gradient(180deg, rgba(245, 193, 74, 0.08), var(--surface));
}

.item h3 {
  margin: 0 0 8px;
  font-family: var(--display);
  font-size: 1.12rem;
  font-weight: 650;
}

.item-meta {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.88rem;
}

.item-meta b { color: var(--ink); font-weight: 700; }

.item-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-right: 8px;
  vertical-align: middle;
}

.badge-pendente { background: rgba(245, 193, 74, 0.16); color: var(--warn); }
.badge-ok { background: rgba(62, 224, 180, 0.14); color: var(--ok); }

.icon-btn {
  height: 40px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 4, 10, 0.72);
  display: none;
  align-items: flex-end;
  z-index: 20;
}

.modal.open { display: flex; }

.sheet {
  width: 100%;
  background: #10151f;
  border-top: 1px solid var(--line);
  border-radius: 24px 24px 0 0;
  padding: 20px 16px calc(18px + var(--safe-b));
  max-height: 88dvh;
  overflow: auto;
}

.sheet h2 { margin-bottom: 12px; }

.grid { display: grid; gap: 12px; }
label { font-weight: 700; font-size: 0.82rem; }
textarea.field { height: 110px; padding: 12px; resize: vertical; }

.sheet-actions {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 8px;
  margin-top: 6px;
}

.btn {
  height: 48px;
  border: 0;
  border-radius: 14px;
  font-weight: 750;
  font-size: 0.92rem;
}

.btn-ghost {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--line);
}
.btn-teal { background: var(--accent); color: #fff; }
.btn-wide { width: 100%; margin-top: 8px; }
.item .btn-wide { margin-top: 12px; height: 44px; }

.resumo {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.resumo div {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
}

.resumo span {
  display: block;
  font-size: 0.64rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.resumo b { display: block; margin-top: 4px; }

.name-picks, .people-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}

.type {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 700;
}

.type.active { background: var(--accent); color: #fff; border-color: transparent; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--tab) + var(--safe-b) + 14px);
  transform: translateX(-50%) translateY(10px);
  background: #eef3fb;
  color: #0a0e16;
  padding: 12px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: 0.22s ease;
  z-index: 30;
  font-weight: 750;
  max-width: 90%;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.banner {
  background: var(--accent-soft);
  color: #c9d8ff;
  border: 1px solid rgba(91, 140, 255, 0.28);
  border-radius: 14px;
  padding: 12px 14px;
  font-weight: 650;
  margin-bottom: 14px;
  line-height: 1.4;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
  background: var(--warn);
}

.status-dot.on {
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
  animation: live-pulse 1.8s ease-in-out infinite;
}

@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.flash-ok .scan-frame span { border-color: var(--ok); }
.flash-ok .scan-line {
  background: linear-gradient(90deg, transparent, var(--ok), transparent);
  box-shadow: 0 0 14px rgba(62, 224, 180, 0.8);
  animation: none;
  top: 50%;
}

@media (prefers-reduced-motion: reduce) {
  .scan-line, .status-dot.on { animation: none; }
}

.welcome {
  align-items: center;
  justify-content: center;
  background: #020308;
  padding: 24px;
}

.welcome-card {
  background: var(--surface);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 24px;
  text-align: left;
}

.help p, .help li { line-height: 1.5; color: var(--muted); }
.help ol { margin: 0 0 14px; padding-left: 1.2rem; display: grid; gap: 10px; }
.help a { color: var(--accent); font-weight: 700; }

.retirado-ok {
  margin: 10px 0 0;
  color: var(--ok);
  font-size: 0.88rem;
  font-weight: 700;
}

@media (max-height: 740px) {
  .scan-hint { top: 84px; }
  .scan-mask { top: 110px; bottom: 248px; }
  .scan-frame { height: 96px; }
  .brand { font-size: 1.12rem; }
}

@media (min-width: 820px) {
  .app {
    max-width: 430px;
    margin: 0 auto;
    min-height: 100dvh;
    box-shadow: 0 0 0 12px #000;
  }
  .tabbar, .modal { max-width: 430px; left: 50%; transform: translateX(-50%); }
  .toast { left: 50%; }
}
