:root{
  --bg:#f8fafc;
  --card:#ffffff;
  --muted:#64748b;
  --text:#0f172a;
  --primary:#e2402a;
  --primary-hover:#af2f1e;
  --danger:#ef4444;
  --ok:#10b981;
  --border:#e2e8f0;
  --shadow:0 10px 30px -10px rgba(0,0,0,.05);
  --radius:14px;
  --max:1100px;
  font-synthesis-weight:none;
}
*{box-sizing:border-box}

/* Previne zoom no duplo clique (Double-tap) no mobile para uma experiência de App nativo */
a, button, input, select, textarea { touch-action: manipulation; }

body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background:
    radial-gradient(900px 600px at 12% 0%, rgba(191,219,254,.50), transparent 60%),
    radial-gradient(900px 600px at 90% 20%, rgba(0,0,0,.04), transparent 60%),
    var(--bg);
  color:var(--text);
}
a{color:inherit}
.wrap{max-width:var(--max); margin:0 auto; padding:28px 18px 60px}
.topbar{
  display:flex; align-items:center; justify-content:space-between; gap:14px;
  padding:16px 18px; border:1px solid var(--border);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(8px);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.brand{display:flex; align-items:center; gap:10px; text-decoration:none}
.logo{
  width:36px; height:36px; border-radius:10px;
  object-fit: cover;
}
.brand b{letter-spacing:.2px}
.actions{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
.btn{
  appearance:none; border:1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
  padding:10px 16px; border-radius:12px; cursor:pointer;
  text-decoration:none; display:inline-flex; align-items:center; gap:8px;
  font-weight: 600; transition: all 0.2s ease;
}
.btn:hover{background: #f8fafc; border-color: #94a3b8;}
.btn:active{transform: scale(0.98);}
.btn.primary{background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: white; border:none; box-shadow: 0 4px 12px rgba(30,58,138,0.25);}
.btn.primary:hover{transform: translateY(-1px); box-shadow: 0 6px 16px rgba(30,58,138,0.35); border:none;}
.btn.danger{background: #fee2e2; border-color: #fca5a5; color: #b91c1c;}
.btn.danger:hover{background: #fecaca;}
.grid{
  margin-top:18px;
  display:grid;
  grid-template-columns: 1.2fr .8fr;
  gap:16px;
}
@media (max-width: 900px){.grid{grid-template-columns:1fr}}
.card{
  border:1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding:16px;
}
.card h2{margin:0 0 10px 0; font-size:18px}
.muted{color:var(--muted)}
.field{display:flex; flex-direction:column; gap:6px; margin-bottom:12px}
.field label{font-size:13px; color:var(--muted)}
.field input, .field textarea, .field select{
  width:100%;
  padding:11px 12px;
  border-radius:12px;
  border:1px solid #cbd5e1;
  background: #ffffff;
  color:var(--text);
  outline:none;
  transition: all 0.2s ease;
}
.field input:focus, .field select:focus, .field textarea:focus{
  border-color: var(--primary); box-shadow: 0 0 0 4px rgba(191, 219, 254, 0.5);
}
.field textarea{min-height:110px; resize:vertical}
.row{display:flex; gap:10px; flex-wrap:wrap}
.row > *{flex:1; min-width: 200px;}
@media (max-width: 480px) {
  .row { flex-direction: column; gap: 6px; }
  .card h2, .card h3, .title { text-align: center !important; }
  .field label { text-align: center; }
  .btn { justify-content: center; }
}
.notice{
  margin-top:10px; padding:10px 12px; border-radius:12px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.85);
}
.notice.ok{border-color: rgba(22,163,74,.35); background: rgba(22,163,74,.08)}
.notice.err{border-color: rgba(220,38,38,.35); background: rgba(220,38,38,.08)}
.list{display:flex; flex-direction:column; gap:10px}
.item{
  border:1px solid var(--border);
  background: rgba(255,255,255,.92);
  border-radius: 14px;
  padding:12px;
}
.item .title{font-weight:700}
.item .meta{color:var(--muted); font-size:13px; margin-top:4px}
.pill{
  display:inline-flex; align-items:center;
  padding:4px 10px; border-radius:999px;
  border:1px solid #bfdbfe;
  background: #dbeafe;
  font-size:12px; color:var(--primary); font-weight:700;
}
.footer{
  margin-top:16px;
  color:var(--muted);
  font-size:12px;
}

/* Eventos - Cards (Grid Responsivo) */
.eventsGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 18px;
  margin-top: 16px;
}
.eventCard {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  text-decoration: none;
  color: var(--text);
}
.eventCard:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px -10px rgba(0,0,0,0.08);
}
.eventCardImg {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background: rgba(0,0,0,0.03);
  border-bottom: 1px solid var(--border);
}
.eventCardBody {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Mobile-first helpers (PWA feel) */
.btn.big{
  padding:14px 16px;
  border-radius:16px;
  font-size:16px;
  justify-content:center;
}
.pill.big{
  font-size:14px;
  padding:6px 12px;
}
.scanWrap{
  position:relative;
  border:1px solid var(--border);
  border-radius:18px;
  overflow:hidden;
  background: rgba(0,0,0,.04);
}
.scanVideo{
  width:100%;
  height:auto;
  display:block;
}
.scanHud{
  position:absolute;
  inset:0;
  pointer-events:none;
  display:flex;
  align-items:center;
  justify-content:center;
}
.scanBox{
  width:min(70vw, 340px);
  aspect-ratio: 1 / 1;
  border-radius:22px;
  border:2px solid rgba(255,255,255,.28);
  box-shadow: 0 0 0 9999px rgba(0,0,0,.25) inset;
  position:relative;
}
.scanBox:before, .scanBox:after{
  content:"";
  position:absolute;
  left:14px; right:14px;
  height:2px;
  top:18%;
  background: rgba(220,38,38,.75);
  filter: drop-shadow(0 0 8px rgba(220,38,38,.35));
  animation: scanline 1.8s ease-in-out infinite;
}
.scanBox:after{
  top:auto;
  bottom:18%;
  opacity:.25;
  animation-duration: 2.4s;
}
@keyframes scanline{
  0%{transform: translateY(0); opacity:.15}
  50%{transform: translateY(180%); opacity:.85}
  100%{transform: translateY(0); opacity:.15}
}
.statusCard{
  padding:14px 14px;
  border-radius:18px;
  border:1px solid var(--border);
  background: rgba(255,255,255,.90);
}
.statusCard.ok{border-color: rgba(22,163,74,.40); background: rgba(22,163,74,.10)}
.statusCard.err{border-color: rgba(220,38,38,.40); background: rgba(220,38,38,.10)}
.statusTitle{
  font-size:18px;
  font-weight:800;
  margin:0 0 6px 0;
}
.statusSub{color:var(--muted); font-size:13px; margin-top:6px}

/* Check-in modal app-like (mobile first) */
.scanModalShell{
  position:fixed;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%);
  width:min(94vw,560px);
  max-height:92dvh;
  z-index:91;
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:8px;
  overflow:hidden;
}
.scanModalBody{
  overflow:auto;
  display:flex;
  flex-direction:column;
  gap:8px;
  overflow-x:hidden;
}
.confirmBtnStrong{
  background: #16a34a !important;
  /* A cor da borda pode ser um pouco mais escura para contraste ou remover */
  /* border-color: #15803d !important; */ 
  color:#ffffff !important;
  font-weight:800;
  min-height:48px;
  box-shadow: 0 8px 22px rgba(22,163,74,.35);
}
@media (max-width: 760px){
  .scanModalShell{
    left:0;
    top:0;
    transform: none; /* remove o centramento */
    width:100vw;
    height:100dvh;
    max-height:none;
    border-radius:0 !important;
    padding:10px;
    margin:0;
  }
  .scanModalShell .row:first-child { padding-bottom: 8px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
  .scanModalShell .scanWrap{
    border-radius:16px;
  }
  .scanModalBody{
    flex:1;
    overflow-x:hidden;
    overflow-y:auto;
    padding-bottom: 0; /* o footer já tem padding top */
  }
  .scanModalBody .row{
    margin-left:0 !important;
    margin-right:0 !important;
    width:100%;
  }
  .scanModalBody .row > *{
    min-width:0;
  }
  .scanVideo{
    width:100%;
    max-width:100%;
    height:auto;
  }
  .scanModalActions{
    background: rgba(255,255,255,.96);
    border-top:1px solid var(--border);
    padding-top:10px;
    padding-bottom:calc(10px + env(safe-area-inset-bottom));
    margin-top:8px;
    width:100%;
    overflow-x:hidden;
    flex-shrink:0;
  }
  .scanModalActions .btn{
    min-height:50px;
    font-size:16px;
  }
  .scanModalActions .confirmBtnStrong{
    width:100%;
  }
}

.checkinConfirmBar,
.scanModalActions{
  display:none;
  flex-direction:column;
  gap:8px;
  width:100%;
}
.checkinConfirmBar .btn,
.scanModalActions .btn{
  flex:none;
  min-width:0;
  width:100%;
}
.checkinConfirmBar .confirmBtnStrong,
.scanModalActions .confirmBtnStrong{
  width:100%;
}

/* Drawer menu (hambúrguer) */
.menuBtn{
  width:44px;
  height:44px;
  padding:0;
  border-radius:14px;
  justify-content:center;
  display:inline-flex; align-items:center;
  color: var(--text);
}

.drawerOverlay{
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.45);
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease;
  z-index: 60;
}
.drawer{
  position:fixed;
  top:0; left:0;
  height:100%;
  width:min(88vw, 330px);
  transform: translateX(-102%);
  transition: transform .22s ease;
  /* menu escuro com letras brancas */
  background: rgba(11,11,13,.96);
  color: #ffffff;
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(255,255,255,.12);
  z-index: 70;
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.drawer .btn{
  color:#ffffff;
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
}
.drawer .pill{
  color: rgba(255,255,255,.78);
  border-color: rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
}
.drawerHead{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:16px;
  border-bottom:1px solid rgba(255,255,255,.12);
  margin-bottom:8px;
}
.drawerTitle{font-weight:800; color:#ffffff}
.drawerList{display:flex; flex-direction:column; gap:8px}
.drawerItem{
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 12px;
  border-radius:16px;
  border:1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color:#ffffff;
  text-decoration:none;
}
.drawerItem.primary{border-color: rgba(59,130,246,.50); background: rgba(59,130,246,.15)}
.drawerItem.danger{border-color: rgba(239,68,68,.50); background: rgba(239,68,68,.15)}
.drawerFoot{margin-top:auto; color: rgba(255,255,255,.65); font-size:12px; padding:6px 2px}

html.drawerOpen .drawerOverlay{opacity:1; pointer-events:auto}
html.drawerOpen .drawer{transform: translateX(0)}

/* Custom Modal Styles */
.custom-modal {
  border: none;
  border-radius: 20px;
  padding: 0;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
  background: rgba(255, 255, 255, 0.98);
  color: #1e293b;
  font-family: inherit;
  margin: auto;
  outline: none;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.5);
  animation: modalReveal 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.custom-modal::backdrop {
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(10px);
  animation: backdropReveal 0.25s ease-out;
}
.modal-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.modal-icon-container {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: #f1f5f9;
  transition: transform 0.3s ease;
}
.custom-modal[open] .modal-icon-container {
  transform: scale(1.05);
}

/* Modal color variations */
.modal-type-success .modal-icon-container { background: #d1fae5; }
.modal-type-error .modal-icon-container { background: #fee2e2; }
.modal-type-warning .modal-icon-container { background: #fef3c7; }
.modal-type-info .modal-icon-container { background: #dbeafe; }

.modal-content {
  width: 100%;
}
.modal-content h3 {
  margin: 0 0 10px 0;
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
}
.modal-content p {
  margin: 0;
  font-size: 15px;
  line-height: 1.6;
  color: #475569;
}
.modal-actions {
  display: flex;
  width: 100%;
  gap: 12px;
  margin-top: 24px;
  justify-content: stretch;
}
.modal-actions .btn {
  flex: 1;
  justify-content: center;
  padding: 12px 18px;
  font-size: 15px;
  border-radius: 12px;
  font-weight: 700;
  min-width: 0;
}
.modal-actions #modalCancelBtn {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}
.modal-actions #modalCancelBtn:hover {
  background: #e2e8f0;
  color: #0f172a;
}

/* Lote Item Responsive Layouts */
.lote-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.lote-details {
  flex: 1;
}
.lote-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .lote-item {
    flex-direction: column;
    align-items: stretch !important;
    gap: 16px;
  }
  .lote-controls {
    justify-content: space-between;
    width: 100%;
  }
  .lote-controls .btn.primary {
    flex: 1;
    text-align: center;
    justify-content: center;
  }
}

/* Custom Quantity Selector Styles */
.qty-selector {
  display: inline-flex;
  align-items: center;
  background: #f1f5f9;
  border-radius: 12px;
  border: 1px solid #cbd5e1;
  overflow: hidden;
  height: 42px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.qty-selector:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(191, 219, 254, 0.5);
}
.qty-btn {
  width: 42px;
  height: 100%;
  border: none;
  background: transparent;
  color: #475569;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  padding: 0;
}
.qty-btn:hover:not(:disabled) {
  background: #e2e8f0;
  color: #0f172a;
}
.qty-btn:active:not(:disabled) {
  transform: scale(0.9);
}
.qty-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.qty-input {
  width: 36px;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  padding: 0;
  margin: 0;
  pointer-events: none;
  -moz-appearance: textfield;
  transition: transform 0.15s ease-out;
}
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

/* Micro-animations */
@keyframes qtyBump {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.qty-input.bump {
  animation: qtyBump 0.15s ease-out;
}

@keyframes modalReveal {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
@keyframes backdropReveal {
  from { opacity: 0; backdrop-filter: blur(0); }
  to { opacity: 1; backdrop-filter: blur(10px); }
}

/* Classes Utilitárias para o Gerenciamento (Formulário Oculto e Busca) */
.form-container-hidden {
  display: none;
  /* Reaproveita a animação modalReveal já existente no seu CSS para uma abertura suave */
  animation: modalReveal 0.3s ease-out; 
}
.search-box {
  margin-bottom: 20px;
  margin-top: 24px;
}
