/* =========================================================================
   LoteScan — Inteligência FEFO • GS1 / ANVISA
   Metodologia de UI Design @whosajid:
   - 3 Camadas de Superfície por Luminosidade HSL (--bg-dark, --bg-base, --bg-light)
   - Física de Luz e Profundidade (Dual-Shadow + Top Inner Highlight)
   - Regra dos 80% de Tipografia (Base 14px, Hierarquia por Peso e Luminosidade)
   ========================================================================= */

:root {
  /* 1. Arquitetura de 3 Camadas de Superfície por Luminosidade HSL (@whosajid) */
  --bg-dark: hsl(214, 22%, 92%);  /* Fundo base da página — mais profundo para destacar os containers principais */
  --bg-base: hsl(210, 20%, 96%);  /* Superfície intermediária para agrupamentos, cabeçalhos de tabela e trilhos */
  --bg-light: hsl(0, 0%, 100%);   /* Superfície elevada mais próxima do usuário: cards principais, aba ativa e botões secundários */

  /* Mapeamento de compatibilidade para variáveis legadas */
  --bg-app: var(--bg-dark);
  --bg-card: var(--bg-light);
  --bg-subtle: var(--bg-base);
  --bg-surface: var(--bg-light);
  --bg-surface-alt: var(--bg-base);
  --bg-input: var(--bg-light);
  --bg-hover: var(--bg-base);

  /* 2. Física de Luz e Profundidade (Dual-Shadow + Top Inner Highlight) */
  --shadow-sm: inset 0 1px 0 0 hsla(0, 0%, 100%, 0.9), 0 1px 2px 0 hsla(220, 40%, 10%, 0.07), 0 2px 6px -1px hsla(220, 40%, 10%, 0.04);
  --shadow-md: inset 0 1px 0 0 hsla(0, 0%, 100%, 1), 0 3px 6px -1px hsla(220, 40%, 10%, 0.09), 0 8px 20px -4px hsla(220, 40%, 10%, 0.06);
  --shadow-inset: inset 0 1.5px 3px 0 hsla(220, 40%, 10%, 0.08), inset 0 -1px 0 0 hsla(0, 0%, 100%, 0.8);

  --shadow-card: var(--shadow-sm);
  --shadow-elevated: var(--shadow-md);

  /* Bordas sutis de contenção (substituídas por contraste de superfície e sombra) */
  --border-color: hsla(215, 22%, 20%, 0.08);
  --border-subtle: hsla(215, 22%, 20%, 0.08);
  --border-strong: hsla(215, 22%, 20%, 0.14);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;

  /* 3. Regra dos 80% de Tipografia (Base 14px) */
  --text-primary: hsl(222, 47%, 11%);
  --text-main: var(--text-primary);
  --text-secondary: hsl(215, 25%, 26%);
  --text-muted: hsl(215, 16%, 44%);

  /* Paleta Farmacêutica Sóbria */
  --brand-primary: #059669;
  --primary: #059669;
  --primary-hover: #047857;
  --primary-soft: hsl(152, 81%, 96%);
  --primary-border: hsl(152, 76%, 80%);

  --secondary: #0284C7;
  --secondary-hover: #0369A1;
  --secondary-soft: #F0F9FF;
  --secondary-border: #BAE6FD;

  --success: #10B981;
  --warning: #F59E0B;
  --danger: #DC2626;

  /* Cores Semânticas Pastel de Alto Contraste */
  --red-bg: #FEF2F2;
  --red-text: #DC2626;
  --red-border: #FECACA;

  --amber-bg: #FFFBEB;
  --amber-text: #D97706;
  --amber-border: #FDE68A;

  --green-bg: #ECFDF5;
  --green-text: #059669;
  --green-border: #A7F3D0;

  /* Fontes */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.mono, code {
  font-family: var(--font-mono) !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.text-red { color: var(--red-text) !important; }
.text-amber { color: var(--amber-text) !important; }
.text-green { color: var(--green-text) !important; }
.text-blue { color: var(--secondary) !important; }

.hidden {
  display: none !important;
}

/* =========================================================================
   TOPBAR ENTERPRISE & NAVEGAÇÃO RESPONSIVA (DESKTOP vs MOBILE)
   ========================================================================= */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--bg-base);
  border-bottom: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1460px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  flex-wrap: wrap;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-shrink: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, hsl(160, 84%, 36%) 0%, hsl(160, 84%, 30%) 100%);
  color: #FFFFFF;
  box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.35), 0 2px 4px hsla(160, 84%, 15%, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.brand-title {
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  white-space: nowrap;
}

.brand-subtitle {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* Trilho das Abas Esculpido (--bg-dark + --shadow-inset) e Aba Ativa Elevada (--bg-light + --shadow-sm) */
.desktop-nav {
  display: none;
  align-items: center;
  gap: 0.15rem;
  background: var(--bg-dark);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-inset);
  border: none;
}

.desktop-nav .desktop-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.36rem 0.62rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.desktop-nav .desktop-tab:hover {
  color: var(--text-primary);
}

.desktop-nav .desktop-tab.active {
  background: var(--bg-light);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.desktop-nav .desktop-tab.active svg {
  color: var(--primary);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.header-actions .btn-outline-sm,
.header-actions .btn-export {
  padding: 0.36rem 0.62rem;
  font-size: 0.8125rem;
  gap: 0.32rem;
}

@media (min-width: 1100px) {
  .header-inner {
    flex-wrap: nowrap;
    gap: 0.6rem;
  }
  .desktop-nav {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
  .header-actions {
    flex-wrap: nowrap;
    flex-shrink: 0;
  }
}

/* Badges & Pills Semânticas */
.badge-pill,
.sem-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.16rem 0.52rem;
  border-radius: 999px;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-green,
.pill-green {
  background: var(--green-bg);
  color: var(--green-text);
  border-color: var(--green-border);
}

.badge-amber,
.pill-yellow {
  background: var(--amber-bg);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

.badge-red,
.pill-red {
  background: var(--red-bg);
  color: var(--red-text);
  border-color: var(--red-border);
}

.badge-teal,
.badge-neutral {
  background: var(--bg-base);
  color: var(--text-secondary);
  border-color: var(--border-color);
}

/* =========================================================================
   BOTÕES COM FÍSICA DE LUZ (@whosajid: Top-Highlight Inset + Dual Shadow)
   ========================================================================= */
.btn-primary,
.btn-primary-cmd,
.btn-primary-sm,
.btn-export {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, hsl(160, 84%, 36%) 0%, hsl(160, 84%, 30%) 100%);
  color: #FFFFFF;
  border: 1px solid hsl(160, 84%, 26%);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.35), 0 2px 4px hsla(160, 84%, 15%, 0.2);
}

.btn-primary:hover:not(:disabled),
.btn-primary-cmd:hover:not(:disabled),
.btn-primary-sm:hover:not(:disabled),
.btn-export:hover:not(:disabled) {
  background: linear-gradient(180deg, hsl(160, 84%, 33%) 0%, hsl(160, 84%, 27%) 100%);
  border-color: hsl(160, 84%, 23%);
}

.btn-secondary,
.btn-secondary-cmd,
.btn-outline-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.46rem 0.85rem;
  border-radius: var(--radius-md);
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover:not(:disabled),
.btn-secondary-cmd:hover:not(:disabled),
.btn-outline-sm:hover:not(:disabled) {
  background: var(--bg-base);
  color: var(--text-primary);
  box-shadow: var(--shadow-md);
}

.btn-outline-sm {
  padding: 0.36rem 0.72rem;
  font-size: 0.84rem;
  border-radius: var(--radius-sm);
}

.btn-warn-outline {
  background: var(--amber-bg);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

.btn-danger-outline,
.btn-danger-sm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--red-bg);
  color: var(--red-text);
  border: 1px solid var(--red-border);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger-outline:hover,
.btn-danger-sm:hover {
  background: #FEE2E2;
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* =========================================================================
   CONTAINER PRINCIPAL E SEÇÕES (CAMADA ELEVADA --bg-light + --shadow-sm)
   ========================================================================= */
.app-container {
  max-width: 1380px;
  margin: 0 auto;
  padding: 1.1rem 1.25rem 5.5rem;
}

.tab-view {
  display: none;
  animation: fadeIn 0.16s ease-out;
}

.tab-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(3px); }
  to { opacity: 1; transform: translateY(0); }
}

.surface-card {
  background: var(--bg-light);
  border: none;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  margin-bottom: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.section-header p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* =========================================================================
   BARRA DE BUSCA ESCULPIDA (--bg-dark + --shadow-inset)
   ========================================================================= */
.command-bar-card {
  background: var(--bg-light);
  border: none;
  border-radius: var(--radius-lg);
  padding: 0.65rem 0.8rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.command-bar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.command-search-wrapper {
  position: relative;
  flex: 1 1 100%;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 0.85rem;
  color: var(--text-muted);
  pointer-events: none;
}

.command-search-wrapper input[type="text"] {
  width: 100%;
  padding: 0.58rem 2.3rem 0.58rem 2.5rem;
  background: var(--bg-dark);
  border: none;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-inset);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.command-search-wrapper input[type="text"]::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.command-search-wrapper input[type="text"]:focus {
  outline: none;
  background: var(--bg-light);
  box-shadow: var(--shadow-sm), 0 0 0 2px hsla(160, 84%, 36%, 0.25);
}

.btn-clear {
  position: absolute;
  right: 0.6rem;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: none;
  background: var(--bg-base);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.btn-clear:hover {
  color: var(--text-primary);
}

.command-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Popover de Resultado Rápido de Lote */
.quick-lote-result {
  margin-top: 0.65rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border-color);
}

.lote-match-box {
  background: var(--bg-base);
  border: none;
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-sm);
}

.lote-match-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
  flex-wrap: wrap;
}

.lote-match-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.3rem;
}

.lote-match-meta {
  display: flex;
  gap: 0.85rem;
  flex-wrap: wrap;
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

.lote-match-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* =========================================================================
   KPI CARDS & FAIXA FINANCEIRA DO PAINEL FEFO (--bg-light + --shadow-sm)
   ========================================================================= */
.semaphore-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 0.85rem;
}

.semaphore-card {
  background: var(--bg-light);
  border: none;
  border-top: 3px solid var(--secondary);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1.1rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.semaphore-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.semaphore-card.active {
  box-shadow: var(--shadow-md), 0 0 0 2px var(--primary);
}

.semaphore-card.sem-red {
  border-top-color: var(--red-text);
}

.semaphore-card.sem-yellow {
  border-top-color: var(--amber-text);
}

.semaphore-card.sem-green {
  border-top-color: var(--green-text);
}

.sem-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.4rem;
}

.sem-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sem-count {
  font-family: var(--font-mono);
  font-size: 1.65rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.15;
}

.semaphore-card.sem-red .sem-count { color: var(--red-text); }
.semaphore-card.sem-yellow .sem-count { color: var(--amber-text); }
.semaphore-card.sem-green .sem-count { color: var(--green-text); }

.sem-sub {
  display: none;
}

/* Strip Financeira Compacta */
.dashboard-fin-strip {
  background: var(--bg-light);
  border: none;
  border-radius: var(--radius-lg);
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow-sm);
}

.fin-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr) auto;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.65rem;
}

.fin-kpi-item {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding-right: 0.75rem;
  border-right: 1px solid var(--border-color);
}

.fin-kpi-label {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
}

.fin-kpi-value {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.fin-kpi-action {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.fin-chart-bar-wrap {
  padding-top: 0.55rem;
  border-top: 1px solid var(--border-color);
}

.fin-chart-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: 0.35rem;
}

/* Trilha da Barra de Progresso Financeira Esculpida (--bg-dark + --shadow-inset) */
.fin-stacked-bar,
.cat-bar-track {
  height: 8px;
  background: var(--bg-dark);
  box-shadow: var(--shadow-inset);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.bar-seg {
  height: 100%;
  transition: width 0.3s ease;
}
.bar-seg.seg-red { background: var(--red-text); }
.bar-seg.seg-yellow { background: var(--amber-text); }
.bar-seg.seg-green { background: var(--green-text); }

/* =========================================================================
   TRILHO DE FILTRO DE PRAZO ESCULPIDO (--bg-dark + --shadow-inset)
   ========================================================================= */
.segmented-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.segmented-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.segmented-control {
  display: inline-flex;
  align-items: center;
  background: var(--bg-dark);
  box-shadow: var(--shadow-inset);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: none;
  gap: 0.2rem;
  overflow-x: auto;
  max-width: 100%;
}

.day-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.34rem 0.72rem;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.day-filter-pill:hover {
  color: var(--text-primary);
}

.day-filter-pill.active {
  background: var(--bg-light);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

.seg-counter {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  padding: 0.04rem 0.36rem;
  border-radius: 999px;
  background: hsla(215, 25%, 20%, 0.08);
  color: var(--text-secondary);
}

.day-filter-pill.active .seg-counter {
  background: var(--primary-soft);
  color: var(--primary);
}

/* =========================================================================
   LISTA DE LOTES FEFO DE ALTA DENSIDADE (ZERO CAIXAS DENTRO DE CAIXAS)
   ========================================================================= */
.products-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.product-card {
  background: var(--bg-light);
  border: none;
  border-left: 3.5px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.05rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.product-card:hover {
  box-shadow: var(--shadow-md);
}

.product-card.status-red { border-left-color: var(--red-text); }
.product-card.status-yellow { border-left-color: var(--amber-text); }
.product-card.status-green { border-left-color: var(--green-text); }

.fefo-row-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1.05fr) minmax(460px, 2.55fr) auto;
  align-items: center;
  gap: 0.85rem;
}

/* Esquerda: Nome do Medicamento (14px 600 --text-primary) + Badges FEFO */
.fefo-row-left {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  min-width: 0;
}

.fefo-title-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prod-title {
  font-size: 0.875rem; /* 14px */
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  word-break: break-word;
}

.fefo-badges-wrap {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.fefo-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.fefo-badge-first {
  background: var(--green-bg);
  color: var(--green-text);
}

.fefo-badge-blocked {
  background: var(--red-bg);
  color: var(--red-text);
}

.fefo-badge-queue {
  background: var(--bg-base);
  color: var(--text-muted);
}

.prod-status-pill {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

.prod-category-line {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.fefo-gtin-inline {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Centro: Colunas Limpas sem Bordas Internas e sem corte (...) em Gôndola e Custo / Total */
.fefo-row-center {
  display: grid;
  grid-template-columns: minmax(76px, 0.68fr) minmax(88px, 0.75fr) minmax(150px, 1.38fr) minmax(175px, 1.55fr);
  gap: 0.75rem;
  align-items: center;
}

body.role-funcionario .fefo-row-center {
  grid-template-columns: minmax(85px, 0.8fr) minmax(95px, 0.85fr) minmax(170px, 1.5fr);
}

.fefo-meta-col {
  display: flex;
  flex-direction: column;
  gap: 0.08rem;
  min-width: 0;
}

.fefo-meta-label {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.2;
}

.fefo-meta-val {
  font-size: 0.875rem; /* 14px */
  font-weight: 600;
  color: var(--text-primary);
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  line-height: 1.35;
}

.fefo-meta-val.mono {
  white-space: nowrap;
}

.fefo-meta-sub {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Direita: Saldo (un) sem caixa interna + Botões Compactos alinhados à direita */
.fefo-row-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.55rem;
  flex-wrap: nowrap;
}

.fefo-stock-readout {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.05rem;
  min-width: 52px;
}

.fefo-stock-num {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.25;
}

.fefo-stock-num small {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

.prod-actions-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.28rem;
  flex-wrap: nowrap;
}

.btn-stock-op,
.btn-card-action {
  background: var(--bg-light);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 500;
  padding: 0.28rem 0.52rem;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

.btn-stock-op:hover,
.btn-card-action:hover {
  background: var(--bg-base);
  box-shadow: var(--shadow-md);
}

.btn-stock-in:hover {
  background: var(--green-bg);
  color: var(--green-text);
  border-color: var(--green-border);
}

.btn-stock-out:hover {
  background: var(--secondary-soft);
  color: var(--secondary);
  border-color: var(--secondary-border);
}

.btn-stock-exp:hover,
.btn-card-delete:hover {
  background: var(--red-bg);
  color: var(--red-text);
  border-color: var(--red-border);
}

/* =========================================================================
   ETAPA 2 & 3 + UPGRADE DE COLETOR DE BOLSO: SCANNER GS1, OCR & INVENTÁRIO
   ========================================================================= */
.scanner-pocket-shell {
  padding: 1.1rem 1.2rem;
}

.scanner-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.scanner-title-group {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}

.scanner-title-group h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.01em;
}

.inventory-compact-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  user-select: none;
}

.inventory-compact-switch input {
  width: 15px;
  height: 15px;
  accent-color: var(--primary);
}

/* Placar em Tempo Real da Sessão de Inventário */
.scanner-scoreboard {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.55rem;
  margin-bottom: 0.85rem;
}

.score-item {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 0.5rem 0.7rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.score-item.score-green { border-top-color: var(--green-text); }
.score-item.score-blue { border-top-color: var(--secondary); }
.score-item.score-amber { border-top-color: var(--amber-text); }

.score-label {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-val {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  line-height: 1.15;
}

.score-item.score-green .score-val { color: var(--green-text); }
.score-item.score-blue .score-val { color: var(--secondary); }
.score-item.score-amber .score-val { color: var(--amber-text); }

.inventory-mode-banner,
.ocr-capture-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.photo-capture-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.photo-icon-circle {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--secondary-soft);
  color: var(--secondary);
  border: 1px solid var(--secondary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.photo-capture-info strong {
  font-size: 0.86rem;
  color: var(--text-main);
}

.photo-capture-info p {
  font-size: 0.76rem;
  color: var(--text-muted);
}

.ocr-card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Viewfinder Profissional Ampliado + HUD Sobreposto */
.camera-viewport-wrapper {
  position: relative;
  width: 100%;
  max-width: 680px;
  height: 340px;
  margin: 0 auto 0.85rem;
  background: #0F172A;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

#scannerVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: filter 0.22s ease;
}

#scannerVideo.video-night-boost {
  filter: brightness(1.85) contrast(1.35);
}

.scan-flash-overlay {
  position: absolute;
  inset: 0;
  background: rgba(16, 185, 129, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease;
  z-index: 4;
}

.scan-flash-overlay.flash-active {
  opacity: 1;
}

.viewfinder-hud-top {
  position: absolute;
  top: 0.65rem;
  left: 0.65rem;
  right: 0.65rem;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  pointer-events: none;
}

.hud-status-left,
.hud-hardware-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  pointer-events: auto;
}

.hud-live-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.65rem;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(6px);
  color: #F8FAFC;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.16);
}

.hud-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94A3B8;
}

.hud-live-pill.scanning .hud-dot {
  background: #10B981;
  box-shadow: 0 0 8px #10B981;
}

.hud-live-pill.cooldown .hud-dot {
  background: #F59E0B;
  box-shadow: 0 0 8px #F59E0B;
}

.hud-cooldown-badge {
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: rgba(217, 119, 6, 0.92);
  color: #FFFFFF;
  font-size: 0.68rem;
  font-weight: 700;
}

.hud-icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.38rem 0.68rem;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.78);
  backdrop-filter: blur(6px);
  color: #F8FAFC;
  border: 1px solid rgba(255, 255, 255, 0.2);
  font-family: var(--font-sans);
  font-size: 0.73rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.hud-icon-btn:hover {
  background: rgba(15, 23, 42, 0.92);
  border-color: rgba(255, 255, 255, 0.4);
}

.hud-icon-btn.torch-active {
  background: #D97706;
  color: #FFFFFF;
  border-color: #FDE68A;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.5);
}

/* Quadro de Mira Centralizado */
.scanner-reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(76%, 320px);
  height: 175px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 12px;
  pointer-events: none;
  z-index: 3;
}

.reticle-corner {
  position: absolute;
  width: 22px;
  height: 22px;
  border-color: #10B981;
  border-style: solid;
}
.reticle-corner.tl { top: -2px; left: -2px; border-width: 3px 0 0 3px; border-top-left-radius: 8px; }
.reticle-corner.tr { top: -2px; right: -2px; border-width: 3px 3px 0 0; border-top-right-radius: 8px; }
.reticle-corner.bl { bottom: -2px; left: -2px; border-width: 0 0 3px 3px; border-bottom-left-radius: 8px; }
.reticle-corner.br { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; border-bottom-right-radius: 8px; }

.reticle-laser {
  position: absolute;
  left: 10px;
  right: 10px;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent, #10B981 20%, #34D399 50%, #10B981 80%, transparent);
  box-shadow: 0 0 8px rgba(16, 185, 129, 0.75);
  animation: laserMove 2.1s infinite ease-in-out;
}

.reticle-caption {
  position: absolute;
  bottom: -28px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 0.7rem;
  font-weight: 600;
  color: #F8FAFC;
  background: rgba(15, 23, 42, 0.72);
  padding: 0.18rem 0.6rem;
  border-radius: 999px;
}

@keyframes laserMove {
  0%, 100% { top: 14%; }
  50% { top: 86%; }
}

.camera-placeholder {
  position: absolute;
  inset: 0;
  z-index: 5;
  background: #F1F5F9;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 1.5rem;
  text-align: center;
  font-size: 0.82rem;
}

.placeholder-icon-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.scanner-controls {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin-bottom: 0.9rem;
  flex-wrap: wrap;
}

.btn-thumb-lg {
  min-height: 42px;
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
}

/* Card / Drawer Compacto de Confirmação Rápida (Ergonomia de Polegar) */
.thumb-drawer-card {
  background: #FFFFFF;
  border: 2px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 1rem 1.1rem;
  margin-top: 0.75rem;
  box-shadow: var(--shadow-elevated);
  animation: fadeIn 0.18s ease-out;
}

.seq-ean-ocr-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem;
  background: var(--amber-bg);
  border: 1px solid var(--amber-border);
  border-left: 4px solid var(--amber-text);
  border-radius: var(--radius-md);
  margin-bottom: 0.85rem;
  flex-wrap: wrap;
}

.seq-ean-ocr-text strong {
  display: block;
  font-size: 0.8rem;
  color: var(--amber-text);
}

.seq-ean-ocr-text span {
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.seq-ean-ocr-btns {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.drawer-fields-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
}

.drawer-col-full {
  grid-column: 1 / -1;
}

/* Barra de Quantidade Rápida (-1, +1, +5, +10) */
.thumb-qty-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.55rem 0.75rem;
  margin: 0.35rem 0 0.8rem;
  flex-wrap: wrap;
}

.thumb-qty-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.thumb-qty-input {
  width: 78px !important;
  text-align: center;
  font-size: 1rem !important;
  font-weight: 700;
  padding: 0.38rem 0.5rem !important;
}

.thumb-qty-Presets {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.btn-qty-preset {
  min-width: 46px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #FFFFFF;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.12s ease;
}

.btn-qty-preset:hover,
.btn-qty-preset:active {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

/* 3 Grandes Botões de Ação Rápida para o Polegar */
.thumb-action-trio {
  display: grid;
  grid-template-columns: 1.5fr 1fr 1.1fr;
  gap: 0.5rem;
}

.btn-thumb-confirm,
.btn-thumb-secondary {
  min-height: 44px;
  font-size: 0.84rem;
  font-weight: 700;
}

/* Modo Desenvolvedor Retrátil */
.dev-simulator-drawer {
  margin-top: 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-app);
  overflow: hidden;
}

.dev-simulator-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.65rem 0.9rem;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  list-style: none;
  user-select: none;
  transition: background 0.15s ease;
}

.dev-simulator-summary::-webkit-details-marker {
  display: none;
}

.dev-simulator-summary:hover {
  background: var(--bg-subtle);
  color: var(--text-main);
}

.dev-sum-left {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.dev-simulator-drawer .gs1-simulator-box {
  margin-top: 0;
  border: none;
  border-top: 1px solid var(--border-color);
  border-radius: 0;
  background: var(--bg-card);
}

.seq-history-box,
.gs1-simulator-box {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 0.85rem;
}

.seq-panel-header,
.seq-history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.seq-alert-msg {
  font-size: 0.8rem;
  margin-bottom: 0.65rem;
}

.manual-gs1-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.4rem 0 0.65rem;
}

.manual-gs1-row input {
  flex: 1;
}

.sample-chips {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.chips-label {
  font-size: 0.73rem;
  font-weight: 600;
  color: var(--text-muted);
}

.chip-btn {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.73rem;
  font-weight: 600;
  padding: 0.28rem 0.6rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary-border);
}

/* =========================================================================
   FORMULÁRIOS E CAMPOS (ABA 3 + MODAIS)
   ========================================================================= */
.gs1-banner {
  padding: 0.75rem 1rem;
  background: var(--green-bg);
  color: var(--green-text);
  border: 1px solid var(--green-border);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  margin-bottom: 0.9rem;
}

.gs1-banner.banner-warn {
  background: var(--amber-bg);
  color: var(--amber-text);
  border-color: var(--amber-border);
}

.form-row-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.85rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
}

.form-row-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.75rem;
}

.form-label {
  font-size: 0.77rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.req {
  color: var(--red-text);
}

input[type="text"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 0.52rem 0.75rem;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 0.84rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

.input-compact {
  width: 240px !important;
  padding: 0.38rem 0.65rem !important;
  font-size: 0.78rem !important;
}

.field-hint {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.photo-preview-container {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.75rem;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.85rem;
}

.photo-preview-container img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border-color);
}

/* =========================================================================
   RELATÓRIOS DE PERDAS & ADMIN / AUDITORIA (ABAS 4 E 5)
   ========================================================================= */
.loss-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem;
  margin-bottom: 1.15rem;
}

.loss-kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-top: 3px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.loss-kpi-card.kpi-red,
.loss-kpi-card.kpi-red-soft { border-top-color: var(--red-text); }
.loss-kpi-card.kpi-amber { border-top-color: var(--amber-text); }
.loss-kpi-card.kpi-blue { border-top-color: var(--secondary); }

.loss-kpi-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.loss-kpi-big {
  font-family: var(--font-mono);
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-main);
}

.loss-kpi-card.kpi-red .loss-kpi-big { color: var(--red-text); }
.loss-kpi-card.kpi-amber .loss-kpi-big { color: var(--amber-text); }
.loss-kpi-card.kpi-blue .loss-kpi-big { color: var(--secondary); }

.loss-kpi-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.report-section-box {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem 1.15rem;
  margin-bottom: 1rem;
}

.report-section-box h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 0.2rem;
}

.report-sub {
  font-size: 0.77rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.admin-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.table-box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.category-chart-container,
.clean-table-list,
.seq-history-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cat-bar-row {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
}

.cat-bar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  margin-bottom: 0.4rem;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.seq-history-item,
.history-row {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  transition: background 0.15s ease;
}

.history-row {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.seq-history-item:hover,
.history-row:hover {
  background: var(--bg-hover);
}

.history-row-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
}

/* =========================================================================
   MODAIS (BACKDROP BLUR 4PX) & TOASTS
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-elevated);
  padding: 1.25rem;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  margin-bottom: 0.9rem;
  border-bottom: 1px solid var(--border-color);
  position: relative;
}

.modal-header h3 {
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--text-main);
}

.modal-header .btn-clear {
  position: static;
}

.modal-body {
  display: flex;
  align-items: stretch;
}

.modal-body img#photoModalImg {
  width: 100%;
  max-height: 65vh;
  object-fit: contain;
  border-radius: var(--radius-md);
}

.stock-modal-info {
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.ocr-progress-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem;
  background: var(--bg-app);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.82rem;
}

.ocr-spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =========================================================================
   BOTTOM NAVIGATION (MOBILE < 768PX) & TOASTS
   ========================================================================= */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border-color);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 0.35rem 0.4rem;
  box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.04);
}

.bottom-nav .nav-item {
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.18rem;
  padding: 0.3rem 0.2rem;
  font-family: var(--font-sans);
  font-size: 0.66rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.bottom-nav .nav-item.active {
  color: var(--primary);
  background: var(--primary-soft);
}

.scan-fab {
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-container {
  position: fixed;
  bottom: 4.5rem;
  right: 1rem;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 360px;
}

.toast {
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-elevated);
  font-size: 0.82rem;
  font-weight: 600;
  animation: fadeIn 0.2s ease-out;
}

/* =========================================================================
   MEDIA QUERIES (DESKTOP >= 768PX vs MOBILE < 768PX)
   ========================================================================= */
@media (min-width: 768px) {
  .desktop-nav {
    display: inline-flex;
  }
  .bottom-nav {
    display: none !important;
  }
  .app-container {
    padding-bottom: 2.5rem;
  }
  .toast-container {
    bottom: 1.5rem;
  }
}

@media (max-width: 1024px) {
  .fefo-row-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }
  .fefo-row-center {
    grid-template-columns: repeat(2, 1fr);
    padding: 0.55rem 0;
    border-top: 1px solid hsla(214, 25%, 84%, 0.45);
    border-bottom: 1px solid hsla(214, 25%, 84%, 0.45);
  }
  .fefo-row-right {
    justify-content: space-between;
  }
  .fin-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .admin-grid-2 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .semaphore-grid,
  .loss-kpi-grid,
  .scanner-scoreboard {
    grid-template-columns: repeat(2, 1fr);
  }
  .camera-viewport-wrapper {
    height: 360px;
  }
  .drawer-fields-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .thumb-action-trio {
    grid-template-columns: 1fr 1fr;
  }
  .thumb-action-trio .btn-thumb-confirm {
    grid-column: 1 / -1;
  }
  .form-row-2,
  .form-row-3,
  .form-row-4,
  .fin-kpi-grid {
    grid-template-columns: 1fr;
  }
  .fin-kpi-item {
    border-right: none;
    padding-right: 0;
  }
  .hide-xs {
    display: none;
  }
  .command-actions {
    width: 100%;
  }
  .command-actions button {
    flex: 1;
  }
  .fefo-row-right {
    flex-direction: column;
    align-items: stretch;
  }
  .fefo-stock-readout {
    text-align: left;
    border-right: none;
    padding-right: 0;
  }
  .prod-actions-group {
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* =========================================================================
   ETAPA 5: SAAS MULTI-FARMÁCIAS (SUPER_ADMIN / CONSOLE SAAS MASTER)
   ========================================================================= */

.tenant-selector-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--bg-dark);
  border: none;
  border-radius: 999px;
  padding: 3px 8px;
  height: 30px;
  box-shadow: var(--shadow-inset);
}

.tenant-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.tenant-status-dot.status-pendente {
  background: var(--warning);
}

.tenant-status-dot.status-bloqueada {
  background: var(--danger);
}

.tenant-select-input {
  border: none !important;
  background: transparent !important;
  font-size: 0.75rem !important;
  font-weight: 600 !important;
  color: var(--text-primary) !important;
  padding: 0 16px 0 2px !important;
  height: 22px !important;
  max-width: 155px;
  cursor: pointer;
  box-shadow: none !important;
}

.saas-master-tab {
  color: var(--text-primary) !important;
  font-weight: 600 !important;
}

.saas-master-tab svg {
  flex-shrink: 0;
  color: #059669;
}

.saas-master-tab.active {
  background: var(--bg-light) !important;
  color: var(--text-primary) !important;
  box-shadow: var(--shadow-sm) !important;
}

.badge-saas-gold {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.04em;
}

/* ==========================================================================
   CONSOLE SAAS B2B ENTERPRISE (PADRÃO STRIPE BILLING / LINEAR / VERCEL + @whosajid)
   ========================================================================== */

.saas-b2b-shell {
  padding-bottom: 24px;
}

.saas-b2b-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid hsla(214, 25%, 82%, 0.6);
}

.saas-b2b-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saas-b2b-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.saas-b2b-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.saas-tech-badge {
  display: inline-flex;
  align-items: center;
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #334155;
  border-radius: 5px;
  padding: 2px 8px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.saas-b2b-subtitle {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-muted);
}

.saas-b2b-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.saas-btn-primary,
.saas-btn-secondary,
.saas-btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 13px;
  border-radius: 7px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.14s ease;
  white-space: nowrap;
}

.saas-btn-primary {
  background: linear-gradient(180deg, hsl(160, 84%, 36%) 0%, hsl(160, 84%, 30%) 100%);
  color: #ffffff;
  border: 1px solid hsl(160, 84%, 26%);
  box-shadow: inset 0 1px 0 hsla(0, 0%, 100%, 0.35), 0 2px 4px hsla(160, 84%, 15%, 0.2);
}

.saas-btn-primary:hover {
  background: linear-gradient(180deg, hsl(160, 84%, 33%) 0%, hsl(160, 84%, 27%) 100%);
}

.saas-btn-secondary {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid hsla(214, 25%, 82%, 0.7);
  box-shadow: var(--shadow-sm);
}

.saas-btn-secondary:hover {
  background: var(--bg-base);
}

.saas-btn-logout {
  background: var(--bg-light);
  color: #b91c1c;
  border: 1px solid #fecaca;
  box-shadow: var(--shadow-sm);
}

.saas-btn-logout:hover {
  background: #fef2f2;
  border-color: #f87171;
}

/* Grid de 4 Indicadores Executivos (Stripe Billing + @whosajid Depth) */
.saas-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 20px 0 24px 0;
}

.saas-kpi-card {
  background: var(--bg-light);
  border: 1px solid hsla(214, 25%, 84%, 0.5);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.saas-kpi-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.saas-kpi-value {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 6px 0;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.saas-kpi-sub-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.saas-kpi-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  flex-shrink: 0;
  display: inline-block;
}

.saas-kpi-dot.dot-green,
.saas-kpi-dot.dot-emerald {
  background: #10b981;
}

.saas-kpi-dot.dot-amber {
  background: #f59e0b;
}

.saas-kpi-dot.dot-red {
  background: #ef4444;
}

.saas-kpi-sub {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  line-height: 1.35;
}

/* Painel & Tabela Executiva de Unidades Licenciadas */
.saas-b2b-card {
  background: var(--bg-light);
  border: 1px solid hsla(214, 25%, 84%, 0.5);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.saas-b2b-card-header,
.saas-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.saas-b2b-card-header h3,
.saas-card-title {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text-primary);
}

.saas-b2b-card-header p,
.saas-card-desc {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.saas-table-panel {
  padding: 0;
  overflow: hidden;
}

.saas-table-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--bg-light);
  border-bottom: 1px solid hsla(214, 25%, 84%, 0.55);
}

.saas-table-toolbar-left,
.saas-toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.saas-section-heading {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
}

.saas-count-pill,
.saas-count-badge {
  background: var(--bg-base);
  color: var(--text-muted);
  border: 1px solid hsla(214, 25%, 82%, 0.6);
  border-radius: 999px;
  padding: 2px 9px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
}

.saas-table-toolbar-right,
.saas-toolbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.saas-search-box {
  position: relative;
  display: flex;
  align-items: center;
}

.saas-search-box svg {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}

.saas-search-box input,
#auditFilterInput {
  height: 32px;
  padding: 0 10px 0 30px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 500;
  color: #0f172a;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  transition: all 0.14s ease;
}

.saas-search-box input {
  width: 270px;
}

#auditFilterInput {
  padding-left: 12px;
}

.saas-search-box input:focus,
#auditFilterInput:focus {
  outline: none;
  background: #ffffff;
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.saas-filter-pills {
  display: inline-flex;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.saas-filter-btn {
  border: none;
  background: transparent;
  color: #64748b;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
}

.saas-filter-btn:hover {
  color: #0f172a;
}

.saas-filter-btn.active {
  background: #ffffff;
  color: #0f172a;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.saas-table-scroll {
  width: 100%;
  overflow-x: auto;
}

.saas-b2b-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.saas-b2b-table thead th {
  background: #f8fafc;
  color: #64748b;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 18px;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

.saas-b2b-table tbody tr {
  border-bottom: 1px solid #f1f5f9;
  transition: background-color 0.12s ease;
}

.saas-b2b-table tbody tr:last-child {
  border-bottom: none;
}

.saas-b2b-table tbody tr:hover {
  background: #f8fafc;
}

.saas-b2b-table tbody td {
  padding: 13px 18px;
  vertical-align: middle;
  font-size: 0.85rem;
  color: #0f172a;
}

.saas-td-primary {
  font-weight: 600;
  color: #0f172a;
  font-size: 0.85rem;
  line-height: 1.35;
}

.saas-td-secondary {
  font-size: 0.76rem;
  font-weight: 400;
  color: #64748b;
  margin-top: 2px;
  line-height: 1.35;
}

.saas-td-mono {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #0f172a;
  font-weight: 600;
}

/* Badges Técnicos de Status da Licença (Com Dot Colorido) */
.saas-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.saas-status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.saas-status-pill.status-ativa {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.saas-status-pill.status-ativa::before {
  background: #10b981;
}

.saas-status-pill.status-atrasada {
  background: #fffbeb;
  color: #b45309;
  border: 1px solid #fde68a;
}

.saas-status-pill.status-atrasada::before {
  background: #f59e0b;
}

.saas-status-pill.status-suspensa {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.saas-status-pill.status-suspensa::before {
  background: #ef4444;
}

/* Botões de Ação Compactos de Alta Precisão na Tabela (Toolbar Horizontal Estilo Stripe / Linear) */
.saas-row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: nowrap;
}

.saas-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
}

.saas-action-charge {
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
}

.saas-action-charge:hover {
  background: #1e293b;
  border-color: #1e293b;
}

.saas-action-inspect {
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
}

.saas-action-inspect:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.saas-action-sim-webhook {
  background: #f8fafc;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.saas-action-sim-webhook:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.saas-action-suspend,
.saas-action-reactivate {
  background: transparent;
  color: #64748b;
  border: 1px solid #cbd5e1;
}

.saas-action-suspend:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}

.saas-action-reactivate:hover {
  background: #ecfdf5;
  border-color: #6ee7b7;
  color: #059669;
}

/* Card "Integração Financeira • Asaas API v3" (Estilo Stripe Dashboard Minimalista) */
.saas-asaas-stripe-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  margin-bottom: 18px;
  overflow: hidden;
}

.saas-asaas-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid #e2e8f0;
  flex-wrap: wrap;
}

.saas-asaas-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saas-asaas-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.saas-stripe-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #334155;
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}

.saas-stripe-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  display: inline-block;
  flex-shrink: 0;
}

.saas-stripe-dot.dot-error {
  background: #ef4444;
}

.saas-asaas-header-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.saas-stripe-btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid #0f172a;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  white-space: nowrap;
}

.saas-stripe-btn-primary:hover {
  background: #1e293b;
  border-color: #1e293b;
}

.saas-stripe-btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  color: #334155;
  border: 1px solid #cbd5e1;
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
  white-space: nowrap;
}

.saas-stripe-btn-secondary:hover {
  background: #f8fafc;
  border-color: #94a3b8;
  color: #0f172a;
}

.saas-asaas-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid #e2e8f0;
  background: #ffffff;
}

.saas-asaas-metric-cell {
  padding: 13px 20px;
  border-right: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saas-asaas-metric-cell:last-child {
  border-right: none;
}

.saas-asaas-metric-label {
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.saas-asaas-metric-value {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
}

.saas-asaas-urls-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 14px 20px 16px;
  background: #ffffff;
}

.saas-asaas-url-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.saas-asaas-field-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.saas-asaas-readonly-input,
.saas-asaas-text-input {
  width: 100%;
  height: 36px;
  padding: 0 11px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 12.5px;
  color: #0f172a;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saas-asaas-readonly-input {
  background: #f8fafc;
  color: #334155;
  user-select: all;
}

.saas-asaas-text-input {
  background: #ffffff;
}

.saas-asaas-text-input:focus {
  outline: none;
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

@media (max-width: 960px) {
  .saas-asaas-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .saas-asaas-metric-cell:nth-child(2) {
    border-right: none;
  }
  .saas-asaas-metric-cell:nth-child(1),
  .saas-asaas-metric-cell:nth-child(2) {
    border-bottom: 1px solid #e2e8f0;
  }
  .saas-asaas-urls-grid {
    grid-template-columns: 1fr;
  }
}

/* Cards de Suporte Inferiores: Telemetria Consolidada e Trilha de Auditoria Master */
.saas-support-grid {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 16px;
}

.saas-support-grid .saas-b2b-card {
  margin-bottom: 0;
}

.saas-telemetry-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.saas-telemetry-item,
.saas-telemetry-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-base);
  border: none;
  border-radius: 8px;
}

.saas-telemetry-label,
.saas-telemetry-key {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

.saas-telemetry-sub {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.saas-telemetry-val {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.saas-telemetry-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--primary-dark);
  background: var(--primary-soft);
  padding: 2px 7px;
  border-radius: 5px;
}

.saas-audit-log-box {
  max-height: 220px;
  overflow-y: auto;
}

/* Banner de Assinatura Bloqueada / Suspensa */
.tenant-blocked-banner {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 5px solid var(--danger);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.tenant-blocked-banner-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 240px;
}

.tenant-blocked-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #b91c1c;
}

.tenant-blocked-text strong {
  display: block;
  color: #991b1b;
  font-size: 0.9rem;
}

.tenant-blocked-text p {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: #7f1d1d;
}

.tenant-blocked-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.btn-danger-cmd {
  background: var(--danger) !important;
  border-color: var(--danger) !important;
  color: #fff !important;
}

.super-admin-inspect-banner {
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-left: 4px solid #0f172a;
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 0.82rem;
  color: #1e293b;
}

.pix-payment-card {
  background: var(--bg-surface-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
}

.pix-key-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface);
  border: 1px dashed var(--brand-primary);
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 8px;
}

.pix-key-box code {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--brand-primary);
  word-break: break-all;
}

@media (max-width: 1024px) {
  .saas-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .saas-support-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 767px) {
  .tenant-select-input {
    max-width: 135px;
  }
  .saas-kpi-grid {
    grid-template-columns: 1fr;
  }
  .saas-search-box input {
    width: 100%;
  }
}

/* ==========================================================================
   CARD CORPORATIVO: SEGURANÇA, ISOLAMENTO MULTI-TENANT & CONFORMIDADE LGPD
   ========================================================================== */

.brand-mark {
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}

.security-lgpd-card {
  background: linear-gradient(180deg, #f8fafc 0%, #ffffff 100%);
  border: 1px solid #cbd5e1;
  border-left: 4px solid #059669;
}

.security-badge-verified {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.security-lgpd-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.security-lgpd-item {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  transition: border-color 0.15s ease;
}

.security-lgpd-item:hover {
  border-color: #94a3b8;
}

.security-lgpd-item-wide {
  grid-column: 1 / -1;
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.security-lgpd-icon {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  color: #0f172a;
}

.security-lgpd-item-wide .security-lgpd-icon {
  background: #dcfce7;
  border-color: #86efac;
  color: #047857;
}

.security-lgpd-item strong {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 3px;
}

.security-lgpd-item p {
  margin: 0;
  font-size: 0.77rem;
  line-height: 1.45;
  color: var(--text-muted);
}

.btn-danger-outline {
  border-color: #fca5a5 !important;
  color: #b91c1c !important;
  background: #fef2f2 !important;
  font-weight: 600 !important;
}

.btn-danger-outline:hover {
  background: #fee2e2 !important;
  border-color: #f87171 !important;
}

@media (max-width: 767px) {
  .security-lgpd-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   PAINEL DO FUNCIONÁRIO 100% ENXUTO E OPERACIONAL (body.role-funcionario)
   Oculta abas administrativas, dados financeiros (R$), planilhas e modo dev
   ========================================================================== */

body.role-funcionario .desktop-tab[data-target="viewReports"],
body.role-funcionario .desktop-tab[data-target="viewAdmin"],
body.role-funcionario .desktop-tab[data-target="viewSaasMaster"],
body.role-funcionario .nav-tab[data-target="viewReports"],
body.role-funcionario .nav-tab[data-target="viewAdmin"],
body.role-funcionario .nav-tab[data-target="viewSaasMaster"],
body.role-funcionario .bottom-nav .nav-item[data-target="viewReports"],
body.role-funcionario .bottom-nav .nav-item[data-target="viewAdmin"],
body.role-funcionario .bottom-nav .nav-item[data-target="viewSaasMaster"],
body.role-funcionario #viewReports,
body.role-funcionario #viewAdmin,
body.role-funcionario #viewSaasMaster,
body.role-funcionario .dashboard-fin-strip,
body.role-funcionario .admin-only-field,
body.role-funcionario .admin-only-cost-col,
body.role-funcionario .admin-only-cost-tag,
body.role-funcionario .card-cost-box,
body.role-funcionario .admin-only-btn,
body.role-funcionario #btnOpenImportModalTop,
body.role-funcionario #btnExportCsv,
body.role-funcionario [data-mov-type="BAIXA_VENCIMENTO"],
body.role-funcionario [data-edit-id],
body.role-funcionario [data-delete-id],
body.role-funcionario #devSimulatorDrawer,
body.role-funcionario #btnTestOcrInForm,
body.role-funcionario #createUserBox {
  display: none !important;
}

/* Ajuste responsivo das grades quando o campo de Custo Unitário (R$) está oculto para FUNCIONARIO */
body.role-funcionario .seq-fields-grid {
  grid-template-columns: 1fr 1fr;
}

body.role-funcionario .form-row-4 {
  grid-template-columns: repeat(3, 1fr);
}

body.role-funcionario #stockMovementForm .form-row-3 {
  grid-template-columns: 1fr 2fr;
}

body.role-funcionario #ocrConfirmModal .form-row-2:last-of-type {
  grid-template-columns: 1fr;
}

@media (max-width: 767px) {
  body.role-funcionario .form-row-4,
  body.role-funcionario #stockMovementForm .form-row-3 {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   FLUXO DE BALCÃO: BADGE LEITOR USB / SEM FIO + DATA DE VALIDADE RÁPIDA (MM/AAAA)
   ========================================================================== */

.badge-usb-ready {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-base);
  color: var(--text-main);
  border: 1px solid hsla(214, 25%, 80%, 0.75);
  box-shadow: var(--shadow-sm);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
  transition: all 0.2s ease;
}

.badge-usb-ready svg {
  color: var(--primary);
  flex-shrink: 0;
}

.badge-usb-ready.badge-usb-active {
  background: #dcfce7;
  color: #065f46;
  border-color: #34d399;
  transform: scale(1.02);
}

.smart-date-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.smart-date-input-wrap .smart-date-text-input {
  width: 100%;
  padding-right: 38px !important;
}

.btn-calendar-trigger {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-calendar-trigger:hover {
  background: var(--bg-base);
  color: var(--primary);
}

.native-date-picker-hidden {
  position: absolute;
  right: 6px;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
  border: 0;
  padding: 0;
}

/* =========================================================================
   Fluxo Zero Dor de Cabeça para Produto Inédito / Etiqueta Interna na Câmera
   ========================================================================= */
.seq-unknown-ean-hero {
  background: hsla(152, 76%, 96%, 0.9);
  border: 1px solid hsla(152, 68%, 40%, 0.45);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.seq-unknown-ean-hero-title {
  font-size: 0.78rem;
  font-weight: 600;
  color: #065f46;
}

@keyframes pulseGreenCameraBtn {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.55), 0 2px 6px rgba(5, 150, 105, 0.25);
    transform: translateY(0);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0), 0 4px 12px rgba(5, 150, 105, 0.35);
    transform: translateY(-1px);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0), 0 2px 6px rgba(5, 150, 105, 0.25);
    transform: translateY(0);
  }
}

.btn-pulse-green-hero {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid #047857;
  background: linear-gradient(180deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  animation: pulseGreenCameraBtn 1.8s infinite ease-in-out;
  transition: filter 0.15s ease, transform 0.1s ease;
}

.btn-pulse-green-hero:hover {
  filter: brightness(1.06);
}

.btn-pulse-green-hero:active {
  transform: scale(0.99);
}

/* =========================================================================
   7 Blindagens Operacionais de Chão de Farmácia (Red Teaming)
   ========================================================================= */

/* 1. Gestão Inteligente de Multi-Lotes (Nova Remessa vs. Lote Existente) */
.multi-lot-decision-box {
  background: var(--bg-base);
  border-left: 3px solid #0284c7;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.multi-lot-info-text {
  font-size: 0.78rem;
  color: var(--text-main);
  line-height: 1.35;
}

.multi-lot-decision-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-multilot-choice {
  flex: 1 1 160px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid rgba(15, 23, 42, 0.14);
  background: var(--bg-light);
  color: var(--text-main);
  transition: all 0.14s ease;
}

.btn-multilot-sum.active {
  background: #0f766e;
  color: #ffffff;
  border-color: #0d9488;
}

.btn-multilot-new {
  border-color: rgba(2, 132, 199, 0.35);
  color: #0369a1;
}

.btn-multilot-new.active,
.btn-multilot-new:hover {
  background: #0284c7;
  color: #ffffff;
  border-color: #0369a1;
}

/* 2a. Barra de Busca Rápida Compacta abaixo do Visor do Scanner */
.scanner-quick-search-wrap {
  position: relative;
  margin-top: 8px;
  margin-bottom: 8px;
}

.scanner-quick-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-light);
  border: 1px solid rgba(15, 23, 42, 0.12);
  border-radius: 8px;
  padding: 6px 10px;
  box-shadow: var(--shadow-sm);
}

.scanner-quick-search-bar svg {
  color: var(--text-muted);
  flex-shrink: 0;
}

.scanner-quick-search-bar input {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 3px 0 !important;
  font-size: 0.81rem !important;
  width: 100%;
  outline: none;
}

.scanner-quick-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 40;
  background: var(--bg-light);
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  max-height: 240px;
  overflow-y: auto;
  padding: 4px;
}

.scanner-quick-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 7px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.79rem;
  color: var(--text-main);
}

.scanner-quick-search-item:hover {
  background: var(--bg-base);
}

/* 2b. Banner Flutuante na Base do Visor para Frascos Curvos / Códigos Amassados */
.curved-bottle-fallback-banner {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 10px;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid rgba(16, 185, 129, 0.7);
  background: rgba(6, 78, 59, 0.92);
  backdrop-filter: blur(6px);
  color: #ecfdf5;
  font-size: 0.79rem;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  transition: transform 0.15s ease, background 0.15s ease;
}

.curved-bottle-fallback-banner:hover {
  background: rgba(4, 120, 87, 0.96);
  transform: translateY(-1px);
}

/* 5. Trava Anti-Duplo Toque (Idempotência em Botões Críticos) */
.btn-processing-lock {
  opacity: 0.72 !important;
  pointer-events: none !important;
  cursor: wait !important;
}

/* 6. Badges Técnicos de Classificação Sanitária Especial (Termolábil & Portaria 344) */
.sanitary-risk-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 5px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.sanitary-badge-thermo {
  background: hsla(199, 92%, 94%, 1);
  color: #0369a1;
  border: 1px solid hsla(199, 84%, 45%, 0.3);
}

.sanitary-badge-controlled {
  background: hsla(262, 83%, 95%, 1);
  color: #5b21b6;
  border: 1px solid hsla(262, 70%, 50%, 0.3);
}

.sanitary-badge-antibiotic {
  background: hsla(32, 95%, 94%, 1);
  color: #9a3412;
  border: 1px solid hsla(32, 85%, 45%, 0.28);
}

/* 7. Barra de Ferramentas FEFO + Botão Copiar Puxada FEFO (WhatsApp) */
.segmented-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.segmented-toolbar-left {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.btn-whatsapp-pull {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: #065f46;
  border-color: rgba(5, 150, 105, 0.32);
  background: var(--bg-light);
  white-space: nowrap;
}

.btn-whatsapp-pull:hover {
  background: hsla(152, 76%, 96%, 1);
  border-color: rgba(5, 150, 105, 0.55);
}

/* =========================================================================
   Refinamentos Mobile iOS/Android & Limpeza Definitiva de Dev/Testes
   ========================================================================= */

/* Oculta 100% Modo Desenvolvedor / Simulador GS1 & Leitor USB para todos os perfis */
#devSimulatorDrawer,
.dev-simulator-drawer,
#btnTestOcrInForm {
  display: none !important;
}

/* Alinhamento limpo do rótulo Nome Comercial + botão secundário compacto quando EAN for inédito */
.form-label-row-compact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.form-label-inline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-compact-cam-fallback {
  padding: 4px 10px !important;
  font-size: 0.74rem !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  line-height: 1.25;
  white-space: nowrap;
}

/* Coluna de Saldo integrada ao grid central no Mobile (< 768px) */
.fefo-mobile-saldo-col {
  display: none;
}

@media (max-width: 767px) {
  .product-card .fefo-row-center {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.55rem 0.65rem;
    padding: 0.6rem 0;
    align-items: start;
  }

  .product-card .fefo-row-center > .fefo-meta-col:nth-child(1),
  .product-card .fefo-row-center > .fefo-meta-col:nth-child(2),
  .product-card .fefo-row-center > .fefo-meta-col:nth-child(3) {
    grid-column: span 2;
  }

  .product-card .fefo-row-center > .admin-only-cost-tag {
    grid-column: span 3;
  }

  .product-card .fefo-row-center > .fefo-mobile-saldo-col {
    display: flex;
    grid-column: span 3;
  }

  body.role-funcionario .product-card .fefo-row-center > .fefo-meta-col:nth-child(1),
  body.role-funcionario .product-card .fefo-row-center > .fefo-meta-col:nth-child(2),
  body.role-funcionario .product-card .fefo-row-center > .fefo-meta-col:nth-child(3),
  body.role-funcionario .product-card .fefo-row-center > .fefo-mobile-saldo-col {
    grid-column: span 3;
  }

  .product-card .fefo-row-right > .fefo-stock-readout {
    display: none;
  }

  .product-card .fefo-row-right {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    padding-top: 2px;
  }

  .product-card .prod-actions-group {
    width: 100%;
    justify-content: flex-start;
    gap: 0.35rem;
  }
}

