:root {
  /* Cores de marca GENOM / União Química — extraídas dos arquivos oficiais de marca */
  --red: #e30613;
  --red-deep: #8e0000;
  --navy: #003674;
  --accent-gradient: linear-gradient(135deg, var(--red), var(--red-deep));

  --teal: #00877a;
  --blue: #003674;
  --green: #1b8a5a;
  --bg: #ffffff;
  --bg-card: #f6f6f7;
  --bg-card-2: #ececed;
  --text: #232323;
  --text-dim: #545759;
  --danger: #c81e2c;
  --radius: 16px;
  --brand-color: var(--red);
}

* { box-sizing: border-box; }

h1, h2, .brand-header h1, .admin-page-header h1 {
  font-family: 'Oswald', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.icon { vertical-align: middle; flex-shrink: 0; color: currentColor; }
.btn .icon { margin-right: 8px; margin-bottom: -3px; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 24px 20px calc(24px + env(safe-area-inset-bottom));
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.screen-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.screen-top-row .btn { width: auto; margin-bottom: 0; }

.brand-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-bottom: 32px;
}
.brand-header img { height: 280px; max-width: 90%; object-fit: contain; }
.brand-header h1 { font-size: 20px; margin: 0; text-align: center; }

.event-banner {
  width: 100%;
  aspect-ratio: 16/7;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 20px;
}
.welcome-text {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  text-align: center;
  margin: 0 0 24px;
}

h2 { font-size: 22px; margin: 0 0 8px; }
p.subtitle { color: var(--text-dim); margin: 0 0 24px; font-size: 15px; line-height: 1.4; }
p.field-hint { color: var(--text-dim); margin: -4px 0 8px; font-size: 12px; line-height: 1.3; }

label {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 6px;
  display: block;
}

input[type="email"],
input[type="text"],
input[type="tel"],
input[type="password"],
input[type="date"],
textarea,
select {
  width: 100%;
  padding: 16px;
  font-size: 17px;
  border-radius: var(--radius);
  border: 1px solid #dcdcde;
  background: var(--bg-card);
  color: var(--text);
  margin-bottom: 16px;
  -webkit-appearance: none;
}
textarea { font-family: inherit; resize: vertical; }
input:focus { outline: 2px solid var(--brand-color); }

.password-field-wrap { position: relative; }
.password-field-wrap input { padding-right: 48px; }
.password-toggle-btn {
  position: absolute;
  right: 14px;
  top: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0;
  display: flex;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='9' viewBox='0 0 14 9'%3E%3Cpath d='M1 1l6 6 6-6' stroke='%239fb0c3' stroke-width='2' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 18px center;
  padding-right: 44px;
}

.btn {
  display: block;
  width: 100%;
  padding: 18px;
  font-size: 17px;
  font-weight: 600;
  border-radius: var(--radius);
  border: none;
  background: var(--brand-color);
  color: #ffffff;
  text-align: center;
  cursor: pointer;
  margin-bottom: 12px;
  min-height: 56px; /* alvo de toque grande pro mobile */
}
.btn:active { opacity: 0.8; }
.btn.secondary { background: transparent; border: 1px solid var(--brand-color); color: var(--brand-color); }
.btn.ghost { background: transparent; color: var(--text-dim); font-weight: 400; }
.btn:disabled { opacity: 0.5; }

.link-row { text-align: center; margin-top: 8px; }
.link-row a { color: var(--brand-color); text-decoration: none; font-size: 15px; }

.error-msg {
  background: rgba(255, 84, 112, 0.12);
  color: var(--danger);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 16px;
}
.success-msg {
  background: rgba(0, 230, 118, 0.12);
  color: var(--green);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  margin-bottom: 16px;
}

.card-list { display: flex; flex-direction: column; gap: 12px; }
.card-option {
  background: var(--bg-card);
  border: 1px solid #dcdcde;
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
}
.card-option:active { border-color: var(--brand-color); }
.card-option .info { flex: 1; }
.card-option .info .name { font-size: 17px; font-weight: 600; }
.card-option .info .meta { font-size: 13px; color: var(--text-dim); }

.event-picker-logo-link { display: block; text-align: center; margin: 0 0 24px; }
.event-picker-logo { height: 48px; width: auto; }

/* Cards quadrados: logo grande ocupando a maior parte, nome do evento abaixo.
   Mobile: 1 por linha, ocupando a largura toda. Desktop: grid de vários por linha. */
.event-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}
.event-card {
  background: var(--bg-card);
  border: 1px solid #dcdcde;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s;
}
.event-card:active { border-color: var(--brand-color); transform: scale(0.99); }
.event-card-logo-box {
  width: 100%;
  aspect-ratio: 1;
  background: var(--bg-card-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.event-card-logo-box img { width: 100%; height: 100%; object-fit: contain; padding: 14%; }
.event-card-logo-box.no-logo { background: var(--accent-gradient); }
.event-card-logo-box.no-logo img { display: none; }
.event-card-info { padding: 16px; text-align: center; }
.event-card-info .name { font-size: 16px; font-weight: 600; }

@media (min-width: 700px) {
  .screen:has(.event-grid) { max-width: 900px; }
  .event-grid { grid-template-columns: repeat(3, 1fr); gap: 20px; }
}
@media (min-width: 1100px) {
  .screen:has(.event-grid) { max-width: 1100px; }
  .event-grid { grid-template-columns: repeat(4, 1fr); }
}

.consent-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 18px;
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 20px;
  max-height: 40vh;
  overflow-y: auto;
}
.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 24px;
}
.checkbox-row input { width: 24px; height: 24px; flex-shrink: 0; margin-top: 2px; }
.checkbox-row span { font-size: 14px; line-height: 1.4; }

.camera-box {
  width: 100%;
  aspect-ratio: 3/4;
  background: #000;
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  margin-bottom: 20px;
}

/* Tela de selfie: cabe inteira na viewport, sem rolagem — só a câmera e o essencial. */
.face-scan-screen {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-top: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
}
.face-scan-screen .screen-top-row { margin-bottom: 4px; flex-shrink: 0; }
.face-scan-subtitle { margin: 0 0 10px; flex-shrink: 0; }
.face-scan-screen .camera-box {
  flex: 1;
  aspect-ratio: unset;
  min-height: 0;
  max-height: 55vh;
  margin-bottom: 12px;
}
.face-scan-screen #camera-error-area { flex-shrink: 0; }
.face-scan-actions { flex-shrink: 0; }
.face-scan-actions .btn { margin-bottom: 8px; }
.face-scan-actions .btn:last-child { margin-bottom: 0; }
.camera-box video, .camera-box img { width: 100%; height: 100%; object-fit: cover; }
.camera-box video.mirrored { transform: scaleX(-1); } /* selfie espelhada, como um espelho de verdade */
.camera-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.camera-placeholder .btn { width: auto; padding: 16px 32px; }
.flash-overlay {
  position: absolute;
  inset: 0;
  background: #ffffff;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  mix-blend-mode: screen; /* ilumina sem cobrir totalmente o preview */
}
.camera-box .face-guide {
  position: absolute;
  inset: 15%;
  border: 3px dashed var(--brand-color);
  border-radius: 50%;
  pointer-events: none;
}

.app-logo-link { display: block; text-align: center; }
.app-logo {
  height: 280px;
  max-width: 90%;
  object-fit: contain;
  margin: 0 auto 12px;
}

.welcome-banner {
  background: var(--accent-gradient);
  border-radius: 14px;
  padding: 16px 18px;
  font-size: 14px;
  line-height: 1.55;
  color: #fff;
  margin-bottom: 16px;
}
.welcome-banner strong { color: #fff; }

.tip-banner {
  background: rgba(0, 212, 184, 0.1);
  border: 1px solid rgba(0, 212, 184, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-dim);
  margin-bottom: 16px;
}
.tip-banner strong { color: var(--text); }

.tabs {
  display: flex;
  background: var(--bg-card);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
  gap: 4px;
}
.tab {
  flex: 1;
  text-align: center;
  padding: 12px 4px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
}
.tab.active { background: var(--brand-color); color: #ffffff; }
.tab-count { font-size: 12px; font-weight: 500; opacity: 0.8; }

.photo-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 90px;
}
.photo-grid-3 { grid-template-columns: repeat(3, 1fr); gap: 6px; }
.photo-grid .photo {
  position: relative;
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg-card);
}
.photo-grid .photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .photo .delete-photo-btn { top: auto; bottom: 4px; right: 4px; cursor: pointer; }
.set-cover-btn {
  position: absolute;
  bottom: 4px;
  left: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
}
.set-cover-btn:hover { background: var(--brand-color); color: #ffffff; }
.face-count-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0,0,0,0.55);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}
.photo-grid .photo .fav-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.select-check {
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.5);
  border: 2px solid rgba(255,255,255,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  cursor: pointer;
  z-index: 2;
}
.select-check.checked {
  background: var(--brand-color);
  border-color: var(--brand-color);
  color: #ffffff;
}

/* Selo de "já baixada" — canto inferior direito, na cor de marca do evento */
.downloaded-check {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.4);
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--text-dim);
}

.progress-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 24px;
}
.progress-modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 32px 24px;
  max-width: 320px;
  width: 100%;
  text-align: center;
}
.progress-modal .spinner { margin-bottom: 16px; width: 32px; height: 32px; }
.progress-modal #progress-modal-icon { color: var(--brand-color); margin-bottom: 12px; display: flex; justify-content: center; }
.progress-modal p { font-size: 15px; line-height: 1.4; margin: 0 0 16px; }
.progress-modal .btn { margin-bottom: 0; }

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.bottom-bar .btn { margin-bottom: 0; }

.empty-state { text-align: center; color: var(--text-dim); padding: 60px 20px; font-size: 15px; }

.spinner {
  width: 24px; height: 24px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--brand-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

.center-loading { display: flex; align-items: center; justify-content: center; flex: 1; }

.pin-input {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 16px;
}
.pin-input input {
  width: 44px;
  height: 56px;
  text-align: center;
  font-size: 22px;
  padding: 0;
  margin-bottom: 0;
}

/* Telas grandes (tablet/desktop) — mobile continua sendo a prioridade visual,
   aqui só aproveitamos o espaço extra sem mudar a experiência em si. */
@media (min-width: 768px) {
  .screen { max-width: 600px; padding-top: 48px; }
  .screen:has(.photo-grid) { max-width: 900px; }
  .photo-grid { grid-template-columns: repeat(5, 1fr); gap: 10px; }
  .photo-grid-3 { grid-template-columns: repeat(3, 1fr); }
  .card-option { cursor: pointer; }
  .btn, .btn.secondary, .btn.ghost { width: auto; min-width: 220px; }
  form .btn, .bottom-bar .btn { width: 100%; }
  .camera-box { max-width: 420px; margin-left: auto; margin-right: auto; }
}

@media (min-width: 1100px) {
  .screen:has(.photo-grid) { max-width: 1100px; }
  .photo-grid { grid-template-columns: repeat(6, 1fr); }
  .photo-grid-3 { grid-template-columns: repeat(3, 1fr); }
}

.photo-grid .photo { cursor: pointer; }

.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: #c9c9cc;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.lightbox-img {
  max-width: 92vw;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
}
.lightbox-close {
  position: absolute;
  top: env(safe-area-inset-top, 16px);
  right: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  color: #ffffff;
  border: none;
  font-size: 20px;
  cursor: pointer;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.18);
  color: #ffffff;
  border: none;
  font-size: 28px;
  cursor: pointer;
}
.lightbox-prev { left: 12px; }
.lightbox-next { right: 12px; }

.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  opacity: 0.6;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
/* Tela de selfie precisa caber sem rolagem nenhuma — esse rodapé fixo do HTML
   (fora do #app) sobraria 54px abaixo da viewport e forçaria scroll. */
body.face-scan-active > .app-footer { display: none; }
/* Trava o scroll da página inteira nessa tela — alguns navegadores mobile
   permitem "rubber-band scroll" no body mesmo com o conteúdo interno cabendo. */
body.face-scan-active { overflow: hidden; height: 100vh; height: 100dvh; }

.guests-table { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.guest-row {
  background: var(--bg-card);
  border: 1px solid #232328;
  border-radius: 14px;
  padding: 16px;
}
.guest-name { font-size: 16px; font-weight: 600; margin-bottom: 2px; }
.badge {
  display: inline-block;
  background: var(--accent-gradient);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-left: 6px;
  vertical-align: middle;
}
.guest-meta { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.guest-stats { display: flex; gap: 14px; flex-wrap: wrap; }
.guest-stats span { font-size: 12px; color: var(--text-dim); background: var(--bg-card-2); padding: 4px 10px; border-radius: 999px; }
