/* ==========================================================================
   SISTEMA DE ALMOXARIFADO INTELIGENTE - CSS DESIGN SYSTEM & STYLES (SPA)
   ========================================================================== */

:root {
  /* Color Palette - Matching Prototype Mockups */
  --primary-blue: #003882;
  --primary-blue-dark: #002860;
  --primary-blue-light: #054494;
  --accent-orange: #D94A11;
  --accent-orange-light: #E64A19;
  --accent-orange-soft: rgba(217, 74, 17, 0.1);
  --accent-green: #2E7D32;
  --accent-green-soft: rgba(46, 125, 50, 0.1);
  --accent-red: #DC2626;
  --accent-red-soft: rgba(220, 38, 38, 0.1);
  
  --bg-app: #F8F9FD;
  --bg-card: #FFFFFF;
  --bg-input: #FFFFFF;
  
  --text-dark: #1E293B;
  --text-muted: #64748B;
  --text-light: #94A3B8;
  
  --border-light: #E2E8F0;
  --border-blue: #003882;
  
  --shadow-sm: 0 2px 8px rgba(0, 56, 130, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 56, 130, 0.08);
  --shadow-lg: 0 16px 32px rgba(0, 56, 130, 0.12);
  
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 24px;
  --radius-pill: 999px;
  
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* ------------------------------------------------------------------
     MOBILE-FIRST FOUNDATION
     Base = celular. Telas maiores recebem incrementos via (min-width).
     ------------------------------------------------------------------ */

  /* Altura real do header. Antes era 64px "chumbado" dentro de vários
     calc(), mas o header encolhia no mobile e a conta ficava errada.
     Agora existe um único lugar de verdade. */
  --header-h: 56px;

  /* Recuos de tela com entalhe (iPhone, Android com barra de gestos).
     Fallback 0px para navegadores sem env(). */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  /* Escala de espaçamento fluida: cresce sozinha com a viewport,
     dispensando redefinir padding a cada breakpoint. */
  --space-2xs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: clamp(14px, 3.5vw, 20px);
  --space-lg: clamp(18px, 5vw, 32px);
  --space-xl: clamp(24px, 7vw, 48px);

  /* Respiro horizontal da página, já somando o safe-area. */
  --gutter: clamp(12px, 4vw, 40px);

  /* Alvo mínimo de toque. 44px é o piso das diretrizes de
     acessibilidade da Apple e do Google — abaixo disso o dedo erra. */
  --tap: 44px;

  /* Largura máxima da coluna de leitura e do container geral. */
  --content-max: 1200px;
  --reading-max: 640px;

  /* Tipografia fluida. O corpo NUNCA fica abaixo de 16px em campos de
     formulário, senão o iOS Safari dá zoom sozinho ao focar o input. */
  --fs-xs: 0.75rem;
  --fs-sm: 0.82rem;
  --fs-base: 1rem;
  --fs-lg: clamp(1.05rem, 2.5vw, 1.25rem);
  --fs-xl: clamp(1.25rem, 4vw, 1.75rem);
}

/* Header ganha altura maior onde sobra espaço. */
@media (min-width: 768px) {
  :root {
    --header-h: 64px;
  }
}

/* Reset & Base Settings */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html {
  /* Impede o iOS de reescalar o texto ao girar o aparelho. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  background-color: var(--bg-app);
  color: var(--text-dark);
  font-size: var(--fs-base);
  line-height: 1.5;
  /* 100dvh acompanha a barra de URL do mobile, que aparece e some.
     Com 100vh puro a página fica alta demais e "pula" ao rolar.
     O 100vh fica como fallback para navegadores antigos. */
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
  margin: 0;
  overflow-x: hidden;
  /* Trava o "pull to refresh" acidental e o encadeamento de scroll
     quando o usuário rola dentro de um modal até o fim. */
  overscroll-behavior-y: contain;
  -webkit-font-smoothing: antialiased;
}

/* Nada pode estourar a largura da tela e criar scroll lateral. */
img, video, canvas, svg, iframe, table, pre {
  max-width: 100%;
}

img, video, canvas, svg {
  height: auto;
}

/* Palavras longas (e-mails, códigos de barras) quebram em vez de
   empurrar o layout para fora da viewport.
   Só overflow-wrap: ele quebra apenas quando a palavra REALMENTE não
   cabe. O word-break: break-word que estava aqui era agressivo demais
   e picotava rótulos normais ("FUNCION/ARIO", "ATIV/O"). */
h1, h2, h3, h4, h5, p, span, td, th, li, label, strong, code, small {
  overflow-wrap: break-word;
}

/* Respeita quem pediu menos movimento no sistema operacional. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Foco visível no teclado, sem poluir o clique do mouse. */
:focus-visible {
  outline: 3px solid var(--accent-orange);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Helper Utilities */
.hide {
  display: none !important;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.text-muted {
  color: var(--text-muted);
}

/* ==========================================================================
   MAIN PRODUCTION APP NAVBAR / HEADER
   ========================================================================== */
.main-app-header {
  width: 100%;
  height: var(--header-h);
  /* Empurra o conteúdo para baixo do entalhe, sem deixar faixa branca:
     a altura cresce, mas o fundo do gradiente cobre a área segura. */
  padding-top: var(--safe-top);
  height: calc(var(--header-h) + var(--safe-top));
  background: linear-gradient(135deg, var(--primary-blue-dark) 0%, var(--primary-blue) 100%);
  color: #FFFFFF;
  padding-right: max(var(--gutter), var(--safe-right));
  padding-left: max(var(--gutter), var(--safe-left));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-xs);
  box-shadow: 0 4px 20px rgba(0, 40, 96, 0.15);
  position: sticky;
  top: 0;
  z-index: 1000;
  flex-wrap: nowrap;
}

.header-brand-container {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  /* Encolhe, mas nunca abaixo de um piso legível: sem esse min-width
     a marca era espremida até virar uma letra só ("A...") em 320px. */
  min-width: min(52vw, 190px);
  flex: 1 1 auto;
}

.header-menu-toggle {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.header-menu-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.brand-logo-text {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  color: var(--accent-orange);
  filter: drop-shadow(0 2px 4px rgba(217, 74, 17, 0.3));
}

.brand-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  /* A marca tem prioridade sobre os controles ao repartir a sobra. */
  flex: 1 1 auto;
}

.brand-name {
  /* Escala com a tela em vez de ter um tamanho fixo reduzido por
     media query. */
  font-size: clamp(0.92rem, 3.4vw, 1.05rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #FFFFFF;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* O subtítulo era display:none no celular — informação simplesmente
   sumia. Agora ele encolhe e trunca, mas continua lá. */
.brand-subtitle {
  font-size: clamp(0.68rem, 2.4vw, 0.8rem);
  font-weight: 500;
  color: #93C5FD;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions-container {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  min-width: 0;
  /* Precisa poder encolher: com flex-shrink:0 este bloco engolia todo
     o espaço e a marca era truncada até virar "A...". */
  flex-shrink: 1;
}

.db-status-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 600;
  color: #E0F2FE;
  flex-shrink: 0;
}

/* No celular a pílula mostra só o ponto de status (o texto viraria uma
   coluna espremida); do tablet para cima o texto volta.
   Continua anunciado para leitores de tela — não é display:none. */
.db-status-pill .db-status-text {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

/* Abaixo de 480px nem a pílula cabe. O MESMO status aparece por
   extenso no drawer (card "Banco de Dados"), então aqui ela sai da
   pintura sem que nenhuma informação se perca. */
@media (max-width: 479.98px) {
  .db-status-pill {
    display: none;
  }
}

@media (min-width: 768px) {
  .db-status-pill {
    padding: 6px 14px;
    font-size: 0.8rem;
  }

  .db-status-pill .db-status-text {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.pulse-dot.green {
  background-color: #22C55E;
  box-shadow: 0 0 8px #22C55E;
}

.user-profile-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 10px;
  min-height: var(--tap);
  border-radius: var(--radius-pill);
  color: #FFFFFF;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
  transition: var(--transition-fast);
}

/* No celular o nome do usuário sai da pílula: ele já aparece por
   extenso no drawer, e mantê-lo aqui espremia a marca até sumir.
   Continua no DOM para leitores de tela — não é display:none.
   A partir de 768px o nome volta a ser exibido. */
.user-profile-pill .user-name {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (min-width: 768px) {
  .user-profile-pill .user-name {
    position: static;
    width: auto;
    height: auto;
    overflow: hidden;
    clip: auto;
    text-overflow: ellipsis;
    min-width: 0;
    /* Trunca proporcionalmente, em vez do max-width: 90px fixo que
       cortava todo mundo no mesmo ponto. */
    max-width: clamp(80px, 14vw, 220px);
  }
}

.user-profile-pill:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.user-profile-pill .profile-icon {
  color: #FDBA74;
}

.user-badge {
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  font-weight: 700;
  /* Sem isto o rótulo quebrava letra por letra ("A/D/M/I/N" na
     vertical) quando o header ficava apertado. */
  white-space: nowrap;
  flex-shrink: 0;
}

/* Abaixo de 480px o nível de acesso sai da pílula do header — ele
   aparece no drawer, no card do usuário. A pílula vira só o ícone,
   que continua sendo o botão de trocar de perfil. */
@media (max-width: 479.98px) {
  .user-profile-pill .user-badge {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  .user-profile-pill {
    padding: 6px;
    width: var(--tap);
    justify-content: center;
  }
}

.header-action-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #FFFFFF;
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  transition: var(--transition-fast);
}

.header-action-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.header-action-btn.action-danger:hover {
  background: rgba(220, 38, 38, 0.4);
  border-color: rgba(220, 38, 38, 0.6);
}

/* ==========================================================================
   RESPONSIVE APP VIEWPORT & CONTAINER
   ========================================================================== */
.app-viewport-container {
  width: 100%;
  min-height: calc(100dvh - var(--header-h));
  display: flex;
  flex-direction: column;
  flex: 1;
  background-color: var(--bg-app);
  padding: 0;
}

/* Fluid Production Responsive Frame */
.phone-frame,
.phone-frame.responsive-frame {
  width: 100%;
  max-width: 100%;
  min-height: calc(100dvh - var(--header-h));
  height: auto;
  background-color: var(--bg-app);
  border-radius: 0 !important;
  box-shadow: none !important;
  border: none !important;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: visible;
}


/* ==========================================================================
   APP HEADER
   ========================================================================== */
.app-header {
  height: 60px;
  background-color: var(--primary-blue);
  color: #FFFFFF;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
  z-index: 90;
  position: relative;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: #FFFFFF;
  text-align: center;
  flex: 1;
}

.header-icon-btn {
  background: transparent;
  border: none;
  color: #FFFFFF;
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  cursor: pointer;
  position: relative;
  transition: var(--transition-fast);
}

.header-icon-btn:hover {
  background-color: rgba(255, 255, 255, 0.15);
}

.header-right-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.notification-dot {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 8px;
  height: 8px;
  background-color: var(--accent-orange);
  border-radius: 50%;
  border: 2px solid var(--primary-blue);
}

/* ==========================================================================
   DRAWER NAVIGATION & BADGES
   ========================================================================== */
.drawer-backdrop {
  /* Era absolute: o fundo escuro rolava junto com a página e deixava
     o topo destampado. Fixed prende na viewport. */
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.drawer-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.nav-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  /* 310px fixos tomavam quase toda a tela de um iPhone SE (320px).
     Agora nunca passa de 86% da largura e sempre sobra área para
     tocar fora e fechar. */
  width: min(310px, 86vw);
  left: calc(-1 * min(310px, 86vw) - 12px);
  height: 100%;
  height: 100dvh;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  padding-left: var(--safe-left);
  background-color: #FFFFFF;
  z-index: 950;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transition: left var(--transition-normal);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.nav-drawer.active {
  left: 0;
}

.drawer-header {
  background: var(--primary-blue);
  color: #FFFFFF;
  padding: 24px 20px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-user {
  display: flex;
  align-items: center;
  gap: 14px;
}

.avatar-circle {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  color: #FFFFFF;
}

.drawer-user h3 {
  font-size: 1.05rem;
  font-weight: 700;
}

.drawer-user p {
  font-size: 0.8rem;
  opacity: 0.85;
  margin-top: 2px;
}

.drawer-tags {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}

/* O padrão é o uso em fundo CLARO (tabelas e cartões). Antes era
   branco sobre branco: o badge de galpão simplesmente não aparecia na
   listagem de estoque. */
.badge-dept {
  display: inline-block;
  background-color: #EEF2F7;
  color: var(--primary-blue);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Dentro do drawer o fundo é azul, então volta a versão translúcida. */
.drawer-header .badge-dept {
  background-color: rgba(255, 255, 255, 0.2);
  color: #FFFFFF;
}

.badge-access {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  /* Rótulo de nível de acesso é uma unidade: nunca quebra em duas
     linhas dentro da pílula. */
  white-space: nowrap;
}

.badge-admin {
  background-color: #FEF3C7;
  color: #92400E;
  border: 1px solid #FCD34D;
}

.badge-operador {
  background-color: #DBEAFE;
  color: #1E40AF;
  border: 1px solid #93C5FD;
}

.badge-funcionario {
  background-color: #E0E7FF;
  color: #3730A3;
  border: 1px solid #C7D2FE;
}

.close-drawer-btn {
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-size: 1.5rem;
  cursor: pointer;
}

.drawer-content {
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.drawer-content h4 {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.drawer-section-title {
  margin-top: 20px;
}

.drawer-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-menu a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-dark);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: var(--transition-fast);
}

.drawer-menu a i {
  font-size: 1.2rem;
  color: var(--text-muted);
}

.drawer-menu a.active,
.drawer-menu a:hover {
  background-color: rgba(0, 56, 130, 0.08);
  color: var(--primary-blue);
  font-weight: 600;
}

.drawer-menu a.active i,
.drawer-menu a:hover i {
  color: var(--primary-blue);
}

.lock-tag {
  margin-left: auto;
  color: #94A3B8;
  font-size: 0.9rem;
}

.drawer-divider {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 18px 0;
}

.db-status-card {
  background: #F1F5F9;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: auto;
}

.db-icon i {
  font-size: 2rem;
  color: #16A34A;
}

.db-info {
  flex: 1;
}

.db-info h5 {
  font-size: 0.85rem;
  color: var(--text-dark);
}

.status-online {
  font-size: 0.75rem;
  color: #16A34A;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-sync-db {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dark);
  transition: var(--transition-fast);
}

.btn-sync-db:hover {
  background: var(--primary-blue);
  color: #FFFFFF;
}

/* ==========================================================================
   MAIN APP SCREEN & VIEWS WRAPPER
   ========================================================================== */
.app-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-app);
}

.views-wrapper {
  flex: 1;
  position: relative;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.step-view {
  display: none;
  flex-direction: column;
  /* Gutter fluido + área segura das laterais (paisagem no iPhone) e
     folga inferior para a barra de gestos do Android/iOS. */
  padding: var(--space-md) max(var(--gutter), var(--safe-right))
           calc(var(--space-lg) + var(--safe-bottom))
           max(var(--gutter), var(--safe-left));
  flex: 1;
  width: 100%;
  /* Centraliza sozinho quando a tela cresce — sem precisar de uma
     media query só para isso. */
  max-width: var(--content-max);
  margin-inline: auto;
  animation: fadeIn 0.3s ease;
}

.step-view.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
  margin-bottom: 16px;
}

.step-footer {
  margin-top: auto;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pagination-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.p-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #CBD5E1;
}

.p-dot.active-orange {
  background-color: var(--accent-orange);
  width: 20px;
  border-radius: var(--radius-pill);
}

.p-dot.active-blue {
  background-color: var(--primary-blue);
  width: 20px;
  border-radius: var(--radius-pill);
}

/* BUTTON SYSTEM */
.primary-btn {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-md);
  transition: var(--transition-fast);
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn-blue {
  background-color: var(--primary-blue);
}

.btn-orange {
  background-color: var(--accent-orange);
}

.sm-btn {
  /* No celular ocupa a linha inteira (é o "Novo Usuário / Novo Insumo"
     do cabeçalho de gestão); vira compacto a partir do tablet. */
  height: var(--tap);
  min-height: var(--tap);
  width: 100%;
  padding: 0 16px;
  font-size: 0.9rem;
}

.secondary-btn {
  width: 100%;
  height: 48px;
  background-color: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-dark);
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.secondary-btn:hover {
  background-color: #F1F5F9;
}

/* ==========================================================================
   STEP 1: VALIDAR CRACHÁ (ENTRADA)
   ========================================================================== */
.nfc-scan-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 32px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 10px;
}

.nfc-icon-wrapper {
  position: relative;
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nfc-badge-shape {
  width: 76px;
  height: 76px;
  border-radius: 20px;
  background: var(--accent-orange-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.nfc-orange-icon {
  font-size: 2.8rem;
  color: var(--accent-orange);
}

.glow-pulse {
  animation: pulseGlow 2s infinite ease-in-out;
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(217, 74, 17, 0.4); }
  70% { box-shadow: 0 0 0 16px rgba(217, 74, 17, 0); }
  100% { box-shadow: 0 0 0 0 rgba(217, 74, 17, 0); }
}

.nfc-welcome-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-dark);
  line-height: 1.4;
}

.simulate-nfc-btn {
  background: #F1F5F9;
  border: 1px solid #CBD5E1;
  color: var(--text-dark);
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition-fast);
}

.simulate-nfc-btn:hover {
  background: var(--accent-orange);
  color: #FFFFFF;
  border-color: var(--accent-orange);
}

.employee-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.emp-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background-color: rgba(0, 56, 130, 0.1);
  color: var(--primary-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
}

.emp-details p {
  font-size: 0.85rem;
  color: var(--text-dark);
  margin-bottom: 2px;
}

.badge-status-card {
  margin-top: 16px;
  display: flex;
  justify-content: center;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
}

.status-orange {
  background: #FFF7ED;
  color: #C2410C;
  border: 1px solid #FFEDD5;
}

.status-green {
  background: #F0FDF4;
  color: #15803D;
  border: 1px solid #DCFCE7;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-orange { background: #EA580C; }
.dot-green { background: #16A34A; }

/* ==========================================================================
   STEP 2: RECONHECIMENTO FACIAL (TOTEM)
   ========================================================================== */
.totem-banner {
  background: linear-gradient(135deg, var(--primary-blue), #0F2042);
  color: #FFFFFF;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  margin-bottom: 14px;
}

.totem-tag {
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #93C5FD;
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.totem-title {
  font-size: 1rem;
  font-weight: 700;
}

.totem-camera-card {
  background: #0F172A;
  border-radius: var(--radius-lg);
  padding: 12px;
  box-shadow: var(--shadow-md);
}

.totem-camera-frame {
  width: 100%;
  height: 220px;
  position: relative;
  background-color: #020617;
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border: 3px solid var(--accent-orange);
  z-index: 10;
}

.top-left { top: 12px; left: 12px; border-right: none; border-bottom: none; }
.top-right { top: 12px; right: 12px; border-left: none; border-bottom: none; }
.bottom-left { bottom: 12px; left: 12px; border-right: none; border-top: none; }
.bottom-right { bottom: 12px; right: 12px; border-left: none; border-top: none; }

.scan-laser {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-orange), transparent);
  box-shadow: 0 0 12px var(--accent-orange);
  z-index: 12;
  opacity: 0;
}

.scan-laser.scanning {
  opacity: 1;
  animation: scanLaser 1.8s infinite ease-in-out;
}

@keyframes scanLaser {
  0% { top: 5%; }
  50% { top: 90%; }
  100% { top: 5%; }
}

.silhouette-icon {
  font-size: 5.5rem;
  color: #334155;
}

.webcam-feed {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.camera-instruction-bar {
  position: absolute;
  bottom: 10px;
  background: rgba(15, 23, 42, 0.85);
  color: #FFFFFF;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.78rem;
  font-weight: 600;
  z-index: 15;
}

.totem-controls-row {
  margin-top: 10px;
  display: flex;
  justify-content: center;
}

.totem-action-btn {
  background: #1E293B;
  color: #F8FAFC;
  border: 1px solid #334155;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.totem-info-card {
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 14px;
  margin-top: 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.form-field-row {
  display: flex;
  gap: 10px;
}

.flex-1 { flex: 1; }
.w-120 { width: 120px; }

.form-field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.custom-input, .custom-select {
  width: 100%;
  max-width: 100%;
  /* 44px = alvo de toque mínimo. */
  min-height: var(--tap);
  height: var(--tap);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  /* 16px cravado. Abaixo disso o iOS Safari dá zoom sozinho ao focar
     o campo e o usuário fica preso numa viewport ampliada. Em telas
     grandes o rem cai para 0.88rem (ver ladder no fim do arquivo). */
  font-size: 16px;
  line-height: 1.4;
  color: var(--text-dark);
  background-color: var(--bg-input);
  outline: none;
  /* Remove o estilo nativo do iOS que ignora border-radius. */
  -webkit-appearance: none;
  appearance: none;
  transition: border-color var(--transition-fast);
}

/* A seta do select some ao tirar o appearance nativo — redesenhada
   como SVG embutido (sem requisição externa). */
.custom-select {
  padding-right: 36px;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 18px;
}

/* Textarea não pode ter altura de input de uma linha. */
textarea.custom-input {
  height: auto;
  min-height: 96px;
  padding: 12px;
  resize: vertical;
}

.custom-input:focus, .custom-select:focus {
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0, 56, 130, 0.1);
}

.match-meter-box {
  background: #F8FAFC;
  border-radius: var(--radius-sm);
  padding: 10px;
  border: 1px solid var(--border-light);
}

.match-meter-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  margin-bottom: 6px;
}

.match-bar-bg {
  height: 8px;
  background: #E2E8F0;
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.match-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-orange), #16A34A);
  transition: width 1s ease;
}

/* ==========================================================================
   STEP 3: BIPAGEM DOS PRODUTOS
   ========================================================================== */
.search-box {
  position: relative;
  margin-bottom: 12px;
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1.1rem;
}

.search-input {
  width: 100%;
  min-height: var(--tap);
  height: var(--tap);
  padding-left: 42px;
  padding-right: 40px;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  /* Mesmo motivo do .custom-input: 16px evita o zoom do iOS. */
  font-size: 16px;
  background: #FFFFFF;
  -webkit-appearance: none;
  appearance: none;
}

.clear-search-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  /* Era um alvo de ~18px: quase impossível de acertar com o dedo. */
  width: var(--tap);
  height: var(--tap);
  display: flex;
  align-items: center;
  justify-content: center;
}

.barcode-scanner-card {
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  border: 1px dashed var(--primary-blue);
  margin-bottom: 16px;
}

.barcode-graphic i {
  font-size: 3rem;
  color: var(--primary-blue);
}

.barcode-text {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 6px 0 10px;
}

.scan-simulate-btn {
  background: rgba(0, 56, 130, 0.08);
  color: var(--primary-blue);
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.products-section {
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

.products-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.products-header h3 {
  font-size: 0.95rem;
  color: var(--text-dark);
}

.add-item-modal-btn {
  background: transparent;
  border: none;
  color: var(--primary-blue);
  font-weight: 700;
  font-size: 0.82rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.product-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 220px;
  overflow-y: auto;
}

.product-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: var(--radius-sm);
  background: #F8FAFC;
  border: 1px solid var(--border-light);
}

.check-orange-icon {
  color: var(--accent-orange);
  font-size: 1.3rem;
}

.product-details {
  flex: 1;
}

.product-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-dark);
}

.product-code {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.product-qty-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qty-actions {
  display: flex;
  gap: 4px;
}

.qty-actions button {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--border-light);
  background: #FFFFFF;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.products-total-row {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border-light);
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   STEP 5: RETIRADA CONCLUÍDA & RECEIPT
   ========================================================================== */
.success-banner-card {
  background: #FFFFFF;
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.success-checkmark-circle {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #DCFCE7;
  color: #16A34A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 12px;
}

.success-message {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-dark);
}

.summary-details-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.summary-item {
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--border-light);
}

.summary-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
}

.blue-bg {
  background: rgba(0, 56, 130, 0.1);
  color: var(--primary-blue);
}

.summary-text h4 {
  font-size: 0.88rem;
  color: var(--text-dark);
}

.summary-text p {
  font-size: 0.8rem;
}

.receipt-actions {
  margin-top: 16px;
}

/* ==========================================================================
   VIEW: GESTÃO DE USUÁRIOS & MANUTENÇÃO DO ALMOXARIFADO
   ========================================================================== */
.management-header {
  display: flex;
  /* Empilhado no celular: título em cima, botão de ação largo embaixo,
     fácil de alcançar com o polegar. */
  flex-direction: column;
  align-items: stretch;
  justify-content: space-between;
  margin-bottom: var(--space-md);
  gap: var(--space-sm);
}

.management-header h2 {
  font-size: var(--fs-xl);
  line-height: 1.25;
}

.section-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.access-warning-card {
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  color: #991B1B;
  padding: 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 16px;
}

.access-warning-card i {
  font-size: 1.5rem;
}

.management-controls {
  display: flex;
  /* Busca e filtros um por linha no celular; lado a lado quando cabe. */
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.filter-flex-1 {
  flex: 1;
  /* min-width: 200px forçava overflow em telas de 320px quando havia
     dois filtros na mesma linha. Zero deixa o flex encolher. */
  min-width: 0;
}

/* STAT CARDS GRID */
.stats-grid {
  display: grid;
  /* 2 colunas já no celular (os números são curtos), virando auto-fit
     conforme a tela cresce. minmax com 0 evita estouro em telas muito
     estreitas — o minmax(130px,...) antigo furava a viewport. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.stat-card {
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  box-shadow: var(--shadow-sm);
}

.stat-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
}

.stat-icon.blue { background: rgba(0, 56, 130, 0.1); color: var(--primary-blue); }
.stat-icon.orange { background: rgba(217, 74, 17, 0.1); color: var(--accent-orange); }
.stat-icon.green { background: rgba(46, 125, 50, 0.1); color: var(--accent-green); }

.stat-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

.stat-info h3 {
  /* Fluido: em 2 colunas num celular estreito o valor "R$ 9.986,20"
     quebrava em duas linhas no meio do número. */
  font-size: clamp(0.92rem, 3.6vw, 1.05rem);
  font-weight: 700;
  color: var(--text-dark);
  white-space: nowrap;
}

.stat-info {
  min-width: 0;
}

/* ==========================================================================
   DATA TABLE — MOBILE-FIRST
   Base (celular): cada <tr> vira um CARTÃO empilhado. Os rótulos das
   colunas reaparecem dentro do cartão via data-label, então some o
   scroll horizontal de 7 a 9 colunas numa tela de 360px.
   A partir de 768px (ver ladder no fim do arquivo) volta a ser tabela.
   ========================================================================== */
.table-container {
  background: transparent;
  border-radius: 0;
  border: none;
  /* Sem moldura no modo cartão: cada cartão tem a sua. */
  overflow-x: visible;
  box-shadow: none;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.83rem;
}

/* Cabeçalho fica escondido no modo cartão, mas de forma acessível:
   continua no fluxo para leitores de tela. */
.data-table thead {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.data-table,
.data-table tbody,
.data-table tr,
.data-table td {
  display: block;
  width: 100%;
}

/* O cartão. Flex em coluna para permitir reordenar: em Estoque e
   Galpões o nome não é a primeira coluna da tabela, mas precisa ser o
   título do cartão. */
.data-table tbody tr {
  display: flex;
  flex-direction: column;
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  padding: var(--space-xs) var(--space-sm);
  margin-bottom: var(--space-sm);
}

/* Título sempre no topo, ações sempre no rodapé, independente da
   ordem das colunas no HTML. */
.data-table tbody td[data-cell="primary"] {
  order: -1;
}

.data-table tbody td[data-cell="actions"] {
  order: 10;
}

.data-table tbody tr:last-child {
  margin-bottom: 0;
}

/* Linha rótulo/valor dentro do cartão. */
.data-table td {
  padding: 9px 0;
  border: none;
  border-bottom: 1px dashed var(--border-light);
  color: var(--text-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  text-align: right;
  min-height: 38px;
}

.data-table td:last-child {
  border-bottom: none;
}

.data-table td[data-label]::before {
  content: attr(data-label);
  font-weight: 600;
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  text-align: left;
  flex-shrink: 0;
  /* O rótulo não pode espremer o valor. */
  max-width: 45%;
}

/* Célula principal (nome do usuário / insumo / galpão) vira o título
   do cartão: sem rótulo, fonte maior, ocupando a linha inteira. */
.data-table td[data-cell="primary"] {
  display: block;
  text-align: left;
  font-size: 0.95rem;
  padding-top: 4px;
  padding-bottom: 10px;
}

.data-table td[data-cell="primary"]::before {
  content: none;
}

/* Botões de ação: barra própria no rodapé do cartão, alinhada à
   esquerda e com alvos de toque de verdade. */
.data-table td[data-cell="actions"] {
  display: flex;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: var(--space-xs);
  text-align: left;
  padding-top: 12px;
  margin-top: 2px;
  border-top: 1px solid var(--border-light);
}

.data-table td[data-cell="actions"]::before {
  content: none;
}

/* A célula de ações herdava .text-right do HTML; no cartão o
   alinhamento é controlado acima. */
.data-table td[data-cell="actions"].text-right {
  text-align: left;
}

/* Linha de estado vazio ("Nenhum usuário encontrado") não é cartão. */
.data-table td[colspan] {
  display: block;
  text-align: center;
  border-bottom: none;
}

.data-table tbody tr:has(td[colspan]) {
  background: #FFFFFF;
  border-style: dashed;
  box-shadow: none;
}

.table-user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 50%;
  background: #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--text-muted);
}

.action-icon-btn {
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  /* Era 30x30: metade do alvo mínimo recomendado. No cartão o botão
     é confortável; em telas grandes volta a ser compacto. */
  width: var(--tap);
  height: var(--tap);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1rem;
  transition: var(--transition-fast);
}

.action-icon-btn:hover {
  background: #E2E8F0;
  color: var(--primary-blue);
}

.action-icon-btn.btn-delete:hover {
  background: #FEE2E2;
  color: var(--accent-red);
}

.action-icon-btn.btn-qr:hover {
  background: #E0F2FE;
  color: var(--primary-blue);
}

.stock-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

/* Mesma regra para a pílula de status ("ATIVO"), que estava quebrando
   como "ATIV / O" na coluna estreita. */
.status-pill {
  display: inline-block;
  white-space: nowrap;
}

.stock-normal { background: #DCFCE7; color: #15803D; }
.stock-low { background: #FFEDD5; color: #C2410C; }
.stock-out { background: #FEE2E2; color: #B91C1C; }

/* ==========================================================================
   MODALS SYSTEM
   ========================================================================== */
/* ==========================================================================
   MODAIS — MOBILE-FIRST (bottom sheet no celular, diálogo no desktop)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  /* 100vw inclui a largura da barra de rolagem e cria scroll lateral
     no desktop; inset:0 resolve sem esse efeito colateral.
     100dvh acompanha a barra de URL do mobile. */
  height: 100dvh;
  background: rgba(15, 23, 42, 0.65);
  backdrop-filter: blur(4px);
  z-index: 99999;
  display: flex;
  /* Ancorado embaixo: o alcance natural do polegar. */
  align-items: flex-end;
  justify-content: center;
  padding: 0;
  animation: fadeIn 0.2s ease;
  overscroll-behavior: contain;
}

.modal-card {
  background: #FFFFFF;
  /* Cantos arredondados só em cima — silhueta de bottom sheet. */
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  width: 100%;
  max-width: 100%;
  /* Nunca cobre a tela inteira: a faixa escura visível no topo indica
     que dá para tocar fora e fechar. */
  max-height: 92dvh;
  padding-bottom: var(--safe-bottom);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: sheetUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Alça visual do bottom sheet (só no celular). */
.modal-card::before {
  content: "";
  width: 40px;
  height: 4px;
  border-radius: var(--radius-pill);
  background: #CBD5E1;
  margin: 10px auto 2px auto;
  flex-shrink: 0;
}

.modal-header {
  padding: 14px var(--space-md);
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  /* Título continua visível ao rolar um formulário longo. */
  position: sticky;
  top: 0;
  background: #FFFFFF;
  z-index: 2;
}

.modal-header h3 {
  font-size: var(--fs-lg);
  color: var(--text-dark);
  min-width: 0;
}

.modal-close-btn {
  background: transparent;
  border: none;
  font-size: 1.4rem;
  color: var(--text-muted);
  cursor: pointer;
  /* Alvo de toque real em vez do ícone nu. */
  width: var(--tap);
  height: var(--tap);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.modal-close-btn:hover {
  background: #F1F5F9;
}

.modal-body {
  padding: var(--space-md);
}

.modal-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.modal-form {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.modal-footer {
  display: flex;
  /* No celular os botões empilham em largura total — mais fáceis de
     acertar e sem risco de o rótulo quebrar dentro do botão.
     O HTML traz "Cancelar" antes de "Salvar"; o column-reverse coloca
     a ação principal ACIMA e o Cancelar por último, que é a convenção
     tanto do Material quanto do action sheet do iOS. Em linha (>=480px)
     a ordem natural volta: Cancelar à esquerda, Salvar à direita. */
  flex-direction: column-reverse;
  gap: var(--space-xs);
  margin-top: var(--space-xs);
  /* Ações sempre visíveis num formulário longo. */
  position: sticky;
  bottom: 0;
  background: #FFFFFF;
  padding-top: var(--space-sm);
  padding-bottom: var(--space-2xs);
}

.modal-footer > * {
  width: 100%;
}

/* User Switcher Cards in Modal */
.user-switch-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.user-switch-btn {
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
}

.user-switch-btn:hover {
  background: rgba(0, 56, 130, 0.05);
  border-color: var(--primary-blue);
}

.user-switch-btn.active {
  background: rgba(0, 56, 130, 0.1);
  border-color: var(--primary-blue);
}

/* Catalog Modal List */
.catalog-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.catalog-item-btn {
  background: #F8FAFC;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  transition: var(--transition-fast);
}

.catalog-item-btn i {
  font-size: 1.5rem;
  color: var(--primary-blue);
}

.catalog-item-btn:hover {
  background: #F1F5F9;
  border-color: var(--primary-blue);
}

/* Receipt Modal Paper */
.receipt-paper {
  max-width: 360px;
  padding: 20px;
  font-family: monospace;
}

.receipt-header { text-align: center; }
.receipt-logo { font-size: 2rem; color: var(--primary-blue); }
.receipt-dashed { border: none; border-top: 1px dashed #CBD5E1; margin: 12px 0; }

.receipt-table {
  width: 100%;
  font-size: 0.8rem;
  margin: 10px 0;
}

.receipt-qrcode-box {
  text-align: center;
}

.fake-qrcode {
  font-size: 4rem;
  color: var(--text-dark);
}

/* TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1E293B;
  color: #FFFFFF;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: slideUp 0.3s ease;
  transition: all 0.3s ease;
}

.toast i {
  color: var(--accent-orange);
  font-size: 1.1rem;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   ESCADA RESPONSIVA — MOBILE-FIRST
   Tudo acima deste ponto é a base: o layout de celular, completo e
   funcional por si só. Daqui para baixo só se ADICIONA conforme a tela
   cresce (min-width). Nenhuma regra esconde conteúdo em tela pequena.

   Degraus:  480px  celular grande / paisagem
             768px  tablet retrato  → tabelas voltam a ser tabelas
            1024px  desktop
            1280px  telas largas
   ========================================================================== */

/* ---------- 480px+ : celular grande e paisagem ---------------------- */
@media (min-width: 480px) {
  /* Onde já cabem dois botões lado a lado, eles saem do empilhamento. */
  .modal-footer {
    flex-direction: row;
    justify-content: flex-end;
  }

  .modal-footer > * {
    width: auto;
    min-width: 130px;
  }

  .sm-btn {
    width: auto;
  }

  .management-header {
    flex-direction: row;
    align-items: flex-start;
  }

  .gps-box-header {
    flex-direction: row;
    align-items: center;
  }

  .btn-capture-gps {
    width: auto;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

/* ---------- 1024px+ : a TABELA volta a ser tabela -------------------
   Testado em 768px e reprovado: com 9 colunas (Estoque) os cabeçalhos
   colidiam e as últimas colunas ficavam cortadas. No tablet em retrato
   o cartão continua sendo a melhor leitura, então a tabela só volta
   quando há largura real para ela.
   -------------------------------------------------------------------- */
@media (min-width: 1024px) {
  .table-container {
    background: #FFFFFF;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    /* Rede de segurança: se ainda assim faltar largura, o scroll fica
       contido no container e nunca na página inteira. */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .data-table {
    display: table;
    width: 100%;
    /* Sem este piso, width:100% espremia as colunas até os títulos se
       sobreporem, em vez de deixar o container rolar. 880px comporta a
       tabela mais larga do sistema (Estoque, 9 colunas) sem colisão e
       ainda cabe sem scroll numa viewport de 1024px. */
    min-width: 880px;
  }

  .data-table thead {
    /* Sai do modo "escondido acessível" e volta a ser cabeçalho. */
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    overflow: visible;
    clip: auto;
    display: table-header-group;
  }

  /* A linha e as células do cabeçalho também precisam voltar: sem
     isto o <tr> continuava display:block e os <th> viravam uma frase
     corrida ("UsuárioCPF / MatrículaCód. Crachá..."). */
  .data-table thead tr {
    display: table-row;
  }

  /* Reposição da regra original de <th>: ao converter a tabela em
     cartões esta declaração foi removida junto, e sem padding os
     títulos encostavam uns nos outros ("EstoqueQtd. MínimaValor"). */
  .data-table th {
    display: table-cell;
    background: #F8FAFC;
    padding: 12px 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    white-space: nowrap;
  }

  .data-table th.text-right {
    text-align: right;
  }

  .data-table tbody {
    display: table-row-group;
  }

  .data-table tbody tr {
    display: table-row;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }

  .data-table tbody tr:hover {
    background-color: #F1F5F9;
  }

  .data-table td {
    display: table-cell;
    width: auto;
    min-height: 0;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--border-light);
    text-align: left;
    vertical-align: middle;
  }

  /* Os rótulos do modo cartão somem — o <thead> assume o papel. */
  .data-table td[data-label]::before {
    content: none;
  }

  .data-table td[data-cell="primary"] {
    display: table-cell;
    font-size: inherit;
    padding: 12px 14px;
  }

  .data-table td[data-cell="actions"] {
    display: table-cell;
    border-top: none;
    border-bottom: 1px solid var(--border-light);
    padding: 12px 14px;
    margin-top: 0;
    white-space: nowrap;
  }

  .data-table td[data-cell="actions"].text-right {
    text-align: right;
  }

  /* Botões de ação voltam ao formato compacto de tabela — no desktop
     o ponteiro do mouse é preciso e 44px ficaria desproporcional. */
  .action-icon-btn {
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
  }
}

/* ---------- 768px+ : tablet ----------------------------------------
   Ajustes que NÃO dependem da tabela: modal vira diálogo, filtros vão
   para a mesma linha, campos voltam ao tamanho compacto.
   -------------------------------------------------------------------- */
@media (min-width: 768px) {
  /* Modal deixa de ser bottom sheet e vira diálogo centralizado. */
  .modal-overlay {
    align-items: center;
    padding: var(--space-md);
  }

  .modal-card {
    border-radius: var(--radius-lg);
    max-width: 480px;
    max-height: 90dvh;
    padding-bottom: 0;
    animation: fadeIn 0.2s ease;
  }

  /* A alça de arrastar só faz sentido no bottom sheet. */
  .modal-card::before {
    content: none;
  }

  .modal-footer {
    position: static;
    padding-bottom: 0;
  }

  /* Em tela grande os campos podem voltar ao tamanho compacto: o zoom
     automático do iOS não existe aqui. */
  .custom-input,
  .custom-select,
  .search-input {
    font-size: 0.88rem;
    height: 42px;
    min-height: 42px;
  }

  .management-controls {
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
  }

  .filter-flex-1 {
    min-width: 220px;
  }

  .catalog-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  /* Cartões de leitura ganham largura confortável e centralizam. */
  .nfc-scan-card,
  .totem-scanner-box,
  .badge-status-card,
  .employee-card,
  .step-footer {
    max-width: var(--reading-max);
    margin-inline: auto;
    width: 100%;
  }
}

/* ---------- 1024px+ : desktop --------------------------------------- */
@media (min-width: 1024px) {
  .step-view {
    padding-block: var(--space-lg);
  }

  .catalog-list {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
  }

  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }

  /* O drawer deixa de ser sobreposição e fica fixo ao lado do conteúdo:
     em desktop não faz sentido esconder a navegação atrás de um botão. */
  .nav-drawer {
    padding-top: calc(var(--header-h) + var(--safe-top));
  }
}

/* ---------- 1280px+ : telas largas ---------------------------------- */
@media (min-width: 1280px) {
  .catalog-list {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  }
}

/* ---------- Paisagem em telas baixas (celular deitado) -------------- */
@media (max-height: 480px) and (orientation: landscape) {
  /* Com pouca altura, o bottom sheet vira tela cheia rolável e o
     cabeçalho encolhe para sobrar área de conteúdo. */
  .modal-card {
    max-height: 100dvh;
    border-radius: 0;
  }

  .leaflet-map-container {
    height: 70dvh;
  }
}

/* ---------- Ponteiro grosso (dedo) em qualquer largura -------------- */
@media (pointer: coarse) {
  /* Vale inclusive para tablets grandes e notebooks com touch, onde a
     largura sozinha não revela que o usuário está usando o dedo. */
  .action-icon-btn,
  .header-icon-btn,
  .modal-close-btn {
    min-width: var(--tap);
    min-height: var(--tap);
  }
}

/* ==========================================================================
   NFC URL AUTHENTICATED BANNER & LOGIN GESTÃO STYLES
   ========================================================================== */
.nfc-success-banner {
  background: linear-gradient(135deg, #F0FDF4 0%, #DCFCE7 100%);
  border: 2px solid #22C55E;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(34, 197, 94, 0.15);
  animation: slideUp 0.3s ease;
  max-width: 640px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

.nfc-success-icon-box {
  font-size: 2.8rem;
  color: #16A34A;
  display: flex;
  align-items: center;
  justify-content: center;
}

.green-pulse-icon {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.nfc-success-details {
  flex: 1;
}

.nfc-auth-badge {
  display: inline-block;
  background-color: #16A34A;
  color: #FFFFFF;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.nfc-user-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #14532D;
  margin-bottom: 2px;
}

.nfc-user-meta {
  font-size: 0.82rem;
  color: #166534;
}

.login-alert-badge {
  background-color: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1E40AF;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.login-alert-badge i {
  font-size: 1.2rem;
  color: var(--primary-blue);
}

/* ==========================================================================
   GESTÃO LOGIN DEDICATED VIEW STYLES
   ========================================================================== */
.gestao-login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px 16px;
  width: 100%;
  flex: 1;
}

.gestao-login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 480px;
  width: 100%;
  padding: 32px 28px;
  animation: slideUp 0.3s ease;
}

.gestao-login-header {
  text-align: center;
  margin-bottom: 24px;
}

.gestao-login-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--primary-blue-dark) 0%, var(--primary-blue) 100%);
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin: 0 auto 16px auto;
  box-shadow: 0 8px 16px rgba(0, 56, 130, 0.2);
}

.gestao-login-header h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-dark);
  margin-bottom: 6px;
}

.gestao-login-header p {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.gestao-login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 12px;
  font-size: 0.95rem;
}

.gestao-login-footer {
  text-align: center;
  margin-top: 12px;
  color: var(--text-light);
}

/* ==========================================================================
   INPUTS REAIS: LEITOR NFC & SCANNER DE CÓDIGO DE BARRAS
   ========================================================================== */

.nfc-reader-input-row {
  display: flex;
  /* Base mobile: campo em cima, botão embaixo. Lado a lado só quando
     há largura real para os dois (>=480px). */
  flex-direction: column;
  gap: 8px;
  align-items: stretch;
  width: 100%;
  margin-top: 14px;
}

@media (min-width: 480px) {
  .nfc-reader-input-row {
    flex-direction: row;
    align-items: center;
  }

  /* O botão deixa de ocupar a linha inteira quando divide espaço. */
  .nfc-reader-input-row .primary-btn {
    width: auto;
    flex-shrink: 0;
    padding-inline: 20px;
  }
}

.nfc-reader-input {
  flex: 1;
  /* A CAUSA DO ESTOURO HORIZONTAL: sem min-width:0 o input nunca
     encolhe abaixo da largura intrínseca do atributo size (~180px),
     e o flex container arrebenta a viewport. */
  min-width: 0;
  /* Herda os 16px do .custom-input. O 0.9rem que estava aqui
     reintroduzia o zoom automático do iOS ao focar o campo. */
  /* Este input fica sobre o cartão BRANCO (.nfc-scan-card), mas estava
     pintado para fundo escuro: texto branco e placeholder branco,
     ou seja, o operador digitava o código do crachá e não via nada. */
  background: #FFFFFF;
  border-color: var(--border-light);
  color: var(--text-dark);
}

.nfc-reader-input::placeholder {
  color: var(--text-light);
}

.nfc-reader-input:focus {
  background: #FFFFFF;
  border-color: var(--primary-blue);
  box-shadow: 0 0 0 3px rgba(0, 56, 130, 0.1);
  outline: none;
}

.barcode-input-row {
  width: 100%;
  margin-top: 12px;
}

.barcode-scanner-input {
  width: 100%;
  text-align: center;
  font-size: 1rem;
  letter-spacing: 0.04em;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: #FFFFFF;
  caret-color: var(--accent-orange);
  animation: blink-border 2s ease-in-out infinite;
}

.barcode-scanner-input::placeholder {
  color: rgba(255,255,255,0.45);
  font-size: 0.85rem;
}

.barcode-scanner-input:focus {
  background: rgba(255,255,255,0.15);
  border-color: var(--accent-orange);
  outline: none;
  animation: none;
}

@keyframes blink-border {
  0%, 100% { border-color: rgba(255,255,255,0.2); }
  50% { border-color: rgba(251,146,60,0.6); }
}

/* ==========================================================================
   MODAL: URL NFC DO FUNCIONÁRIO
   ========================================================================== */

.nfc-url-modal-card {
  max-width: 480px;
  width: 95%;
}

.nfc-url-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.nfc-url-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
}

.nfc-url-copy-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.nfc-url-input {
  flex: 1;
  font-size: 0.78rem;
  background: #F8FAFC;
  color: var(--text-dark);
  cursor: text;
  font-family: 'Courier New', monospace;
}

.qrcode-section-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dark);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.nfc-url-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  background: #F1F5F9;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  line-height: 1.4;
}

/* ==========================================================================
   QR CODE CONTAINER & MODAL DE INSUMO
   ========================================================================== */

.qrcode-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  background: #FFFFFF;
  border: 2px dashed var(--border-light);
  border-radius: var(--radius-md);
  min-height: 180px;
}

.qrcode-container canvas {
  border-radius: 4px;
  display: block;
}

.qrcode-large {
  min-height: 240px;
}

.qrcode-item-modal-card {
  max-width: 380px;
  width: 95%;
}

.qrcode-item-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.qrcode-item-nome {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-dark);
  margin: 0;
}

.qrcode-info-row {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  background: #F8FAFC;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  width: 100%;
  justify-content: center;
}

.qrcode-info-row code {
  font-size: 0.95rem;
  color: var(--primary-blue);
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   GESTÃO DE GALPÕES, MAPA LEAFLET & GEOLOCALIZAÇÃO GPS
   ========================================================================== */

.modal-lg {
  max-width: 680px !important;
  width: 95% !important;
}

.galpoes-map-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.map-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 10px;
}

.map-title-area {
  display: flex;
  align-items: center;
  gap: 10px;
}

.map-title-area i {
  font-size: 1.5rem;
  color: var(--primary-blue);
}

.map-title-area h4 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
}

.map-title-area span {
  font-size: 0.8rem;
  display: block;
}

.map-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.map-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  color: var(--primary-blue);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.map-action-btn:hover {
  background: var(--primary-blue);
  color: #FFFFFF;
  border-color: var(--primary-blue);
}

.leaflet-map-container {
  width: 100%;
  /* Era 380px fixos: sobrava mapa e faltava tela num celular deitado.
     Agora acompanha a altura da viewport com piso e teto. */
  height: clamp(240px, 45dvh, 460px);
  z-index: 1;
  background: #E2E8F0;
}

/* GPS Capture Box in Modal */
.gps-capture-box {
  background: linear-gradient(135deg, #F0F9FF 0%, #E0F2FE 100%);
  border: 1px solid #BAE6FD;
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 14px 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.gps-box-header {
  display: flex;
  /* Base mobile: empilhado, botão de capturar GPS em largura total. */
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.gps-header-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
}

.gps-phone-icon {
  font-size: 1.8rem;
  color: #0284C7;
  background: #FFFFFF;
  padding: 8px;
  border-radius: 12px;
  box-shadow: 0 2px 6px rgba(2, 132, 199, 0.15);
}

.gps-header-info h5 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0369A1;
}

.gps-header-info p {
  margin: 0;
  font-size: 0.8rem;
  color: #0C4A6E;
}

.btn-capture-gps {
  display: inline-flex;
  align-items: center;
  /* Base mobile: largura total e centralizado. */
  width: 100%;
  justify-content: center;
  min-height: var(--tap);
  gap: 8px;
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  color: #FFFFFF;
  border: none;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
  transition: all var(--transition-fast);
}

.btn-capture-gps:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
  background: linear-gradient(135deg, #0369A1 0%, #075985 100%);
}

.btn-capture-gps:active {
  transform: translateY(0);
}

.btn-capture-gps.loading {
  opacity: 0.85;
  pointer-events: none;
}

.btn-capture-gps.loading i {
  animation: spin 1s linear infinite;
}

.gps-status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: #FFFFFF;
  font-size: 0.82rem;
  color: #0369A1;
  border: 1px dashed #7DD3FC;
}

.gps-status-indicator.success {
  background: #DCFCE7;
  color: #166534;
  border-color: #86EFAC;
}

.gps-status-indicator.error {
  background: #FEE2E2;
  color: #991B1B;
  border-color: #FCA5A5;
}

.modal-mini-map-wrapper {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-map-hint {
  font-size: 0.75rem;
  color: #0369A1;
  display: flex;
  align-items: center;
  gap: 4px;
}

.modal-mini-map {
  width: 100%;
  height: 180px;
  border-radius: var(--radius-sm);
  border: 1px solid #CBD5E1;
  z-index: 1;
}

/* Leaflet Custom Marker & Pins */
.custom-map-pin {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  border: 2px solid #FFFFFF;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.custom-map-pin:hover {
  transform: rotate(-45deg) scale(1.15);
}

.custom-map-pin i {
  transform: rotate(45deg);
  font-size: 1.1rem;
  color: #FFFFFF;
}

.custom-map-pin.pin-active {
  background: linear-gradient(135deg, #16A34A 0%, #15803D 100%);
}

.custom-map-pin.pin-maintenance {
  background: linear-gradient(135deg, #EA580C 0%, #C2410C 100%);
}

.custom-map-pin.pin-inactive {
  background: linear-gradient(135deg, #DC2626 0%, #991B1B 100%);
}

.custom-map-pin.pin-user {
  background: linear-gradient(135deg, #0284C7 0%, #0369A1 100%);
  border-radius: 50%;
  transform: none;
}

.custom-map-pin.pin-user i {
  transform: none;
}

/* Custom Popup Design */
.leaflet-popup-content-wrapper {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 0 !important;
  overflow: hidden;
}

.leaflet-popup-content {
  margin: 0 !important;
  line-height: 1.4 !important;
}

.popup-galpao-card {
  padding: 14px 16px;
  /* min-width fixo estourava o popup do Leaflet para fora do mapa em
     telas estreitas. O min() trava no que a tela realmente comporta. */
  min-width: min(220px, 62vw);
  max-width: min(280px, 78vw);
}

.popup-galpao-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 8px;
}

.popup-galpao-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  margin: 0;
}

.popup-galpao-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  text-transform: uppercase;
}

.popup-galpao-badge.badge-ativo {
  background: #DCFCE7;
  color: #166534;
}

.popup-galpao-badge.badge-manutencao {
  background: #FFEDD5;
  color: #C2410C;
}

.popup-galpao-badge.badge-inativo {
  background: #FEE2E2;
  color: #991B1B;
}

.popup-galpao-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.popup-galpao-info strong {
  color: var(--text-dark);
}

.popup-galpao-actions {
  display: flex;
  gap: 6px;
}

.btn-popup-action {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-popup-edit {
  background: var(--primary-blue);
  color: #FFFFFF;
}

.btn-popup-route {
  background: #0284C7;
  color: #FFFFFF;
}

.btn-popup-action:hover {
  opacity: 0.9;
  transform: translateY(-1px);
}

/* Responsiveness for Galpões on Mobile Phone View */
/* (O antigo bloco @media (max-width: 600px) foi absorvido: a altura do
   mapa agora é clamp() fluida e as regras de GPS viraram base
   mobile-first, revertidas na escada min-width abaixo.) */

/* ==========================================================================
   PERFIS DE RESOLUÇÃO E FORMATOS DE TELA POR EQUIPAMENTO (MULTITERMINAL)
   ========================================================================== */

/* 1. Modo Equipamento: Totem de Entrada (Portrait Vertical 1080x1920) */
.phone-frame.mode-portrait-totem {
  max-width: 480px;
  width: 100%;
  min-height: 880px;
  border-radius: 36px;
  margin: 16px auto;
  box-shadow: 0 25px 60px -15px rgba(0, 31, 77, 0.35);
  border: 4px solid rgba(0, 56, 130, 0.15);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Modo Equipamento: Estação de Cadastro & Gestão (Desktop Widescreen 1920x1080) */
.phone-frame.mode-desktop-wide {
  max-width: 1380px;
  width: 96%;
  min-height: 820px;
  border-radius: 16px;
  margin: 16px auto;
  box-shadow: 0 20px 50px -10px rgba(15, 23, 42, 0.2);
  border: 1px solid var(--border-light);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 3. Modo Equipamento: Totem de Compra / Bipagem (Tablet Touch Kiosk 1024x768) */
.phone-frame.mode-tablet-touch {
  max-width: 860px;
  width: 92%;
  min-height: 840px;
  border-radius: 24px;
  margin: 16px auto;
  box-shadow: 0 20px 50px -10px rgba(0, 56, 130, 0.25);
  border: 3px solid rgba(0, 56, 130, 0.12);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 4. Modo Equipamento: Totem Validador de Saída (Display Compacto 720x1280) */
.phone-frame.mode-compact-exit {
  max-width: 440px;
  width: 92%;
  min-height: 720px;
  border-radius: 30px;
  margin: 16px auto;
  box-shadow: 0 20px 50px -12px rgba(16, 185, 129, 0.25);
  border: 3px solid rgba(16, 185, 129, 0.2);
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   SELETOR DE TERMINAL E INDICADOR DE LOTAÇÃO NO HEADER
   ========================================================================== */

.terminal-selector-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-pill);
  padding: 4px 12px;
  color: #FFFFFF;
  font-size: 0.82rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.terminal-selector-pill:hover {
  background: rgba(255, 255, 255, 0.25);
}

.terminal-mode-select {
  background: transparent;
  border: none;
  color: #FFFFFF;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  outline: none;
  font-family: inherit;
}

.terminal-mode-select option {
  background: #002855;
  color: #FFFFFF;
}

.lotacao-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-pill);
  padding: 5px 14px;
  color: #FFFFFF;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.lotacao-pill.lotado {
  background: rgba(220, 38, 38, 0.25);
  border-color: rgba(220, 38, 38, 0.5);
  color: #FCA5A5;
}

/* ==========================================================================
   ALERTA DE LOTAÇÃO MÁXIMA NO TOTEM DE ENTRADA
   ========================================================================== */

.lotacao-alert-banner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #FEF2F2;
  border: 2px solid #EF4444;
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
  animation: pulseWarning 2s infinite ease-in-out;
}

.lotacao-alert-icon {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #FEE2E2;
  color: #DC2626;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.lotacao-alert-info h4 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #991B1B;
  margin-bottom: 3px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.lotacao-alert-info p {
  font-size: 0.82rem;
  color: #B91C1C;
  line-height: 1.4;
  margin: 0;
}

@keyframes pulseWarning {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* ==========================================================================
   TRAVA DE IDENTIFICAÇÃO NO TOTEM DE COMPRA (STEP 3)
   ========================================================================== */

.compra-auth-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
}

.compra-auth-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #EFF6FF;
  color: var(--primary-blue);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 16px;
}

.compra-auth-card h3 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.compra-auth-card p {
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 440px;
  margin: 0 auto 20px;
  line-height: 1.5;
}

.compra-auth-input-row {
  display: flex;
  gap: 10px;
  max-width: 480px;
  margin: 0 auto;
}

.compra-auth-alert {
  margin-top: 18px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: #FEF2F2;
  border: 1px solid #FCA5A5;
  color: #991B1B;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.85rem;
  text-align: left;
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-6px); }
  40%, 80% { transform: translateX(6px); }
}

.compra-buyer-badge {
  display: flex;
  align-items: center;
  gap: 16px;
  background: #F0FDF4;
  border: 1px solid #86EFAC;
  border-radius: var(--radius-md);
  padding: 14px 18px;
  margin-bottom: 20px;
}

.buyer-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #DCFCE7;
  color: #16A34A;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.buyer-details {
  flex: 1;
}

.buyer-tag {
  font-size: 0.72rem;
  font-weight: 800;
  color: #15803D;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.buyer-details h4 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 2px 0;
}

.buyer-details p {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin: 0;
}

.btn-cancel-buyer {
  background: #FEE2E2;
  color: #DC2626;
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.btn-cancel-buyer:hover {
  background: #FCA5A5;
  transform: scale(1.05);
}

/* ==========================================================================
   QR CODE DE SAÍDA NO STEP 5
   ========================================================================== */

.step5-exit-card {
  background: #F8FAFC;
  border: 1.5px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 18px;
  margin: 20px 0;
  text-align: center;
}

.step5-exit-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.step5-exit-header i {
  font-size: 1.6rem;
  color: var(--primary-blue);
}

.step5-exit-header h4 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.step5-qrcode-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.step5-code-badge {
  background: #E2E8F0;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 0.82rem;
  color: var(--text-primary);
}

/* ==========================================================================
   TOTEM VALIDADOR DE SAÍDA (VIEW-TOTEM-SAIDA)
   ========================================================================== */

.exit-banner {
  background: linear-gradient(135deg, #065F46 0%, #059669 100%) !important;
}

.saida-scanner-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 28px 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.qr-scanner-visual {
  display: flex;
  justify-content: center;
  margin-bottom: 18px;
}

.qr-scanner-frame {
  width: 220px;
  height: 220px;
  position: relative;
  background: #0F172A;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
}

.qr-bg-silhouette {
  font-size: 7rem;
  color: rgba(255, 255, 255, 0.12);
}

.saida-instruction {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 380px;
  margin: 0 auto 20px;
}

.saida-input-row {
  display: flex;
  gap: 8px;
  max-width: 440px;
  margin: 0 auto 16px;
}

.saida-code-input {
  font-family: 'Courier New', monospace;
  font-weight: 700;
  letter-spacing: 1px;
}

.door-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.door-status-pill.locked {
  background: #FEF2F2;
  color: #DC2626;
  border: 1px solid #FCA5A5;
}

.door-status-pill.unlocked {
  background: #DCFCE7;
  color: #16A34A;
  border: 1px solid #86EFAC;
  animation: pulseGreen 1.5s infinite;
}

@keyframes pulseGreen {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(22, 163, 74, 0); }
}

.saida-feedback-card {
  background: #FFFFFF;
  border: 2px solid #10B981;
  border-radius: var(--radius-lg);
  padding: 30px 24px;
  text-align: center;
  box-shadow: 0 15px 35px -10px rgba(16, 185, 129, 0.2);
  animation: slideUp 0.4s ease;
}

.saida-success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #DCFCE7;
  color: #10B981;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 14px;
}

.saida-feedback-card h3 {
  font-size: 1.3rem;
  font-weight: 800;
  color: #065F46;
  margin-bottom: 6px;
}

.saida-feedback-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.saida-vaga-info {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: #ECFDF5;
  color: #047857;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-size: 0.85rem;
  font-weight: 600;
}

/* ==========================================================================
   GESTÃO DE EQUIPAMENTOS & MONITOR DE SESSÕES ATIVAS
   ========================================================================== */

.inline-config-box {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.sm-input {
  width: 70px !important;
  padding: 6px 8px !important;
  text-align: center;
  font-size: 1.1rem !important;
  font-weight: 800;
}

.sm-btn-inline {
  padding: 6px 12px !important;
  font-size: 0.85rem !important;
  border-radius: var(--radius-sm) !important;
}

.monitor-sessoes-card {
  background: #FFFFFF;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 18px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.monitor-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.monitor-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.monitor-title i {
  font-size: 1.5rem;
  color: #10B981;
}

.monitor-title h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-primary);
}

.badge-fase {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-fase.fase-entrada {
  background: #FEF3C7;
  color: #B45309;
}

.badge-fase.fase-compra {
  background: #DBEAFE;
  color: #1D4ED8;
}

.badge-fase.fase-concluida {
  background: #DCFCE7;
  color: #15803D;
}

/* Badge de resolução dos terminais no menu drawer */
.badge-terminal-res {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-pill);
  background: #E0F2FE;
  color: #0369A1;
  margin-left: auto;
}

/* Card de Sucesso de Entrada (Totem 1 - Porta Destravada) */
.totem-entry-success-card {
  background: #FFFFFF;
  border: 2px solid #10B981;
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  text-align: center;
  box-shadow: 0 15px 35px -10px rgba(16, 185, 129, 0.25);
  margin-top: 18px;
  animation: slideUp 0.35s ease;
}

.entry-success-icon-box {
  font-size: 3.2rem;
  color: #10B981;
  margin-bottom: 6px;
}

.entry-success-badge {
  display: inline-block;
  background: #DCFCE7;
  color: #15803D;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.entry-direction-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  color: #1D4ED8;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin: 16px 0;
  text-align: left;
}

.entry-direction-pill i {
  font-size: 1.4rem;
  flex-shrink: 0;
}

.entry-actions-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

