/* ==========================================================================
   Reusable UI components
   ========================================================================== */

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 16px;
  font-size: var(--text-sm);
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--color-primary);
  color: var(--color-text-inverse);
}

.btn--primary:hover:not(:disabled) {
  background: var(--color-primary-hover);
}

.btn--outline {
  background: var(--color-surface);
  border-color: var(--color-border-strong);
  color: var(--color-text-secondary);
}

.btn--outline:hover:not(:disabled) {
  background: var(--color-surface-muted);
}

.btn--danger {
  background: var(--color-danger);
  color: var(--color-text-inverse);
}

.btn--danger:hover:not(:disabled) {
  background: var(--color-danger-hover);
}

.btn--sm {
  padding: 6px 10px;
  font-size: var(--text-xs);
}

.btn--block {
  width: 100%;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-primary);
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn--danger {
  color: var(--color-danger);
}

/* ---------- Step card shell ---------- */
.step-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-6);
}

.step-card + .step-card {
  margin-top: var(--space-5);
}

.step-card__top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-5);
}

.step-card__heading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.step-card__icon {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-card__title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

/* ---------- Badges / pills ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.badge--blue {
  background: var(--color-primary-light-strong);
  color: var(--color-primary-active);
}

.badge--green {
  background: var(--color-success-light);
  color: var(--color-success-text);
}

.badge--gray {
  background: var(--color-surface-muted);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.badge--amber {
  background: var(--color-warning-light);
  color: var(--color-warning-text);
}

/* Employer brand tertiary accent (--color-accent) as a border on top of the same warning tint
   badge--amber already uses (they're the same base yellow — see tokens.css) — a small decorative
   detail per the token's own usage guidance, not a distinct fill. Used to flag "Afastado" in the
   Funcionários step's table, visually distinct from badge--amber's own (unrelated) meanings
   elsewhere (pending status, "sem itens"). */
.badge--tertiary {
  background: var(--color-warning-light);
  color: var(--color-warning-text);
  border: 1px solid var(--color-accent);
}

/* Fotos detectadas pelo spoofing / marcadas como suspeitas (ver fotosSuspeitasScreen.js) —
   primeiro uso de vermelho em badge, o resto do conjunto não tinha essa cor. */
.badge--danger {
  background: var(--color-danger-light);
  color: var(--color-danger);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-secondary);
  font-size: var(--text-sm);
  font-weight: 600;
  padding: 8px 14px;
  border-radius: var(--radius-full);
  flex: none;
  white-space: nowrap;
}

.pill:hover {
  background: var(--color-surface-muted);
}

.pill[data-active="true"] {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-text-inverse);
}

.pill-row {
  display: flex;
  gap: var(--space-2);
  padding-bottom: 4px;
}

.filters-row {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  align-items: flex-end;
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.pagination__info {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  white-space: nowrap;
}

/* ---------- Inputs ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field__label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
  letter-spacing: 0.02em;
}

.input,
.select {
  width: 100%;
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  background: var(--color-surface);
  color: var(--color-text);
}

.input:focus,
.select:focus {
  border-color: var(--color-primary);
}

.input:disabled,
.select:disabled {
  background: var(--color-surface-muted);
  color: var(--color-text-faint);
  border-color: var(--color-border);
  cursor: not-allowed;
}

.input--sm,
.select--sm {
  padding: 6px 8px;
  font-size: var(--text-sm);
  border-radius: var(--radius-sm);
}

.search-field {
  position: relative;
  margin-bottom: var(--space-5);
}

.search-field svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}

.search-field .input {
  padding-left: 42px;
  border-radius: var(--radius-md);
}

/* ---------- Autocomplete (employee-history's search-by-nome — see employeeHistoryScreen.js) ---------- */
.autocomplete__suggestions {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
}

.autocomplete__suggestion {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: none;
  cursor: pointer;
}

.autocomplete__suggestion:last-child {
  border-bottom: none;
}

.autocomplete__suggestion:hover {
  background: var(--color-surface-muted);
}

.autocomplete__suggestion--empty {
  color: var(--color-text-muted);
  cursor: default;
}

.autocomplete__suggestion--empty:hover {
  background: none;
}

.autocomplete__suggestion-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.autocomplete__suggestion-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* ---------- Checkbox ---------- */
.checkbox {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: 2px solid var(--color-border-strong);
  accent-color: var(--color-primary);
  flex: none;
  cursor: pointer;
}

/* ---------- Cards grid (companies / EPIs) ---------- */
.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
}

@media (min-width: 620px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- EPI item card ---------- */
.epi-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  background: var(--color-surface);
  cursor: pointer;
}

.epi-card[data-selected="true"] {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
}

.epi-card__top {
  display: flex;
  gap: var(--space-3);
}

.epi-card__body {
  flex: 1;
  min-width: 0;
}

.epi-card__tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.epi-card__name {
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.epi-card__config {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px dashed var(--color-border);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.ca-link {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--color-primary);
}

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: var(--space-5);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-5);
}

.tabs__item {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: var(--space-3) 2px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  margin-bottom: -1px;
}

.tabs__item[data-active="true"] {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

/* ---------- Table ---------- */
.table-wrap {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.table th {
  text-align: left;
  font-size: 0.6875rem;
  letter-spacing: 0.03em;
  color: var(--color-text-faint);
  font-weight: 700;
  background: var(--color-surface-muted);
  padding: var(--space-3);
  white-space: nowrap;
  border-bottom: 1px solid var(--color-border);
}

.table td {
  padding: var(--space-3);
  border-bottom: 1px solid var(--color-border);
  vertical-align: middle;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.table td:has(ul) {
  white-space: normal;
}

.table tr:last-child td {
  border-bottom: none;
}

.table tbody tr:hover {
  background: var(--color-surface-muted);
}

/* Rows the user can click anywhere on to toggle selection (not just the
   checkbox) — scoped so it doesn't apply to review/edit tables. */
.table--selectable tbody tr {
  cursor: pointer;
}

/* Freezes the checkbox + FUNCIONÁRIO columns so they stay visible while the
   rest of a wide table scrolls horizontally underneath — needs an opaque
   background on both cells since sticky content must cover what scrolls by. */
.table--frozen-cols th:first-child,
.table--frozen-cols td:first-child {
  position: sticky;
  left: 0;
  /* min/max lock this to an exact width — table auto-layout treats a plain
     `width` as a hint it can override, which would throw off the next
     column's sticky `left` offset. */
  width: 44px;
  min-width: 44px;
  max-width: 44px;
  background: var(--color-surface);
}

.table--frozen-cols th:nth-child(2),
.table--frozen-cols td:nth-child(2) {
  position: sticky;
  left: 44px;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
}

.table--frozen-cols th:first-child,
.table--frozen-cols th:nth-child(2) {
  background: var(--color-surface-muted);
  z-index: 2;
}

.table--frozen-cols td:first-child,
.table--frozen-cols td:nth-child(2) {
  z-index: 1;
}

/* Em telas estreitas, congelar nome JUNTO do checkbox faz a 2ª coluna sozinha (nome sem quebra,
   ver `.table td` acima) ocupar a largura visível inteira — sobra zero espaço para qualquer outra
   coluna aparecer, não importa quanto se role. Descongela só o nome (mantém o checkbox fixo, que
   é estreito e nunca é o problema): a partir daqui a linha inteira — nome, cargo, supervisor,
   turma, matrícula — rola junta, como nas outras tabelas do app. */
@media (max-width: 640px) {
  .table--frozen-cols th:nth-child(2),
  .table--frozen-cols td:nth-child(2) {
    position: static;
    border-right: none;
  }
}

/* Collapses to icon-only at tablet and below, freeing width for the
   FUNCIONÁRIO column in the Revisão table. */
@media (max-width: 1024px) {
  .action-label {
    display: none;
  }
}

.table-person {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.table-person__avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-surface-muted);
  border: 1px solid var(--color-border);
  color: var(--color-text-faint);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.table-person__name {
  font-weight: 600;
  color: var(--color-text);
}

.utility-links {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin: var(--space-3) 0 var(--space-4);
  font-size: var(--text-sm);
}

/* ---------- On/off switch (e.g. "Não incluir afastados" — step2-funcionarios.js) ---------- */
.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.switch__track {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
  transition: background 0.15s ease;
}

.switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--color-surface);
  border-radius: 50%;
  transition: transform 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

.switch input:checked + .switch__track {
  background: var(--color-primary);
}

.switch input:checked + .switch__track .switch__thumb {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch__track {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ---------- Callout / info box ---------- */
.callout {
  display: flex;
  gap: var(--space-3);
  background: var(--color-primary-light);
  border: 1px solid var(--color-primary-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.callout svg {
  color: var(--color-primary);
  flex: none;
  margin-top: 2px;
}

.callout__title {
  font-weight: 700;
  color: var(--color-text);
  font-size: var(--text-sm);
}

.callout__desc {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ---------- Empty state ---------- */
.empty-state {
  text-align: center;
  padding: var(--space-8) var(--space-4);
  color: var(--color-text-muted);
}

.empty-state svg {
  margin: 0 auto var(--space-3);
  color: var(--color-text-faint);
}

/* Segunda linha do estado vazio — o "e agora?" abaixo da constatação. Menor e
   mais apagada que a primeira, para não competir com ela. */
.empty-state__hint {
  margin-top: var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-text-faint);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 16, 33, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-5);
  z-index: var(--z-modal);
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 2 * var(--space-5));
  display: flex;
  flex-direction: column;
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5);
  border-bottom: 1px solid var(--color-border);
}

.modal__title {
  font-size: var(--text-md);
  font-weight: 700;
}

.modal__close {
  background: none;
  border: none;
  color: var(--color-text-faint);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.modal__close:hover {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.modal__body {
  padding: var(--space-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.field-row {
  display: flex;
  gap: var(--space-2);
}

.field-row > input[data-uf] {
  max-width: 70px;
  text-transform: uppercase;
  text-align: center;
}

@media (max-width: 480px) {
  .epi-card__config {
    grid-template-columns: 1fr;
  }
}

/* ---------- Toast ---------- */
.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: var(--z-toast);
  width: 100%;
  max-width: 360px;
  padding: 0 var(--space-4);
}

.toast {
  background: var(--color-toast-bg);
  color: var(--color-text-inverse);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  animation: toast-in 0.2s ease;
}

.toast[data-tone="success"] svg {
  color: #4ADE80;
}

.toast[data-tone="danger"] svg {
  color: #F87171;
}

.toast[data-tone="warn"] svg {
  color: var(--color-warning);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Background sync bar ("Sincronizar Tudo", assíncrono) ---------- */
.bg-sync-bar {
  position: fixed;
  left: var(--space-5);
  bottom: var(--space-5);
  z-index: var(--z-bg-sync);
  width: 100%;
  max-width: 320px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-3) var(--space-2);
  animation: bg-sync-in 0.25s ease;
}

.bg-sync-bar__row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.bg-sync-bar__icon {
  display: inline-flex;
  flex-shrink: 0;
  color: var(--color-primary);
}

.bg-sync-bar__icon.is-spinning svg {
  animation: spin 1s linear infinite;
}

.bg-sync-bar__label {
  flex: 1;
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bg-sync-bar__cancel {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  border-radius: var(--radius-full);
  cursor: pointer;
}

.bg-sync-bar__cancel:hover:not(:disabled) {
  background: var(--color-surface-muted);
  color: var(--color-text);
}

.bg-sync-bar__cancel:disabled {
  opacity: 0.4;
  cursor: default;
}

.bg-sync-bar__track {
  margin-top: var(--space-2);
  height: 3px;
  border-radius: var(--radius-full);
  background: var(--color-border);
  overflow: hidden;
}

.bg-sync-bar__fill {
  height: 100%;
  background: var(--color-primary);
  border-radius: var(--radius-full);
  transition: width 0.4s ease;
}

@keyframes bg-sync-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 480px) {
  .bg-sync-bar {
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
    width: auto;
    max-width: none;
  }
}

/* ---------- Account drawer (hamburger menu) ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 16, 33, 0.55);
  z-index: var(--z-modal);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.drawer-overlay.is-open {
  opacity: 1;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 320px;
  background: var(--color-surface);
  box-shadow: var(--shadow-lg);
  z-index: calc(var(--z-modal) + 1);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.22s ease;
}

.drawer.is-open {
  transform: translateX(0);
}

.drawer__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5);
  background: linear-gradient(135deg, var(--color-header-from), var(--color-header-to));
  color: var(--color-text-inverse);
  flex: none;
}

.drawer__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex: none;
}

.drawer__identity {
  flex: 1;
  min-width: 0;
}

.drawer__name {
  font-weight: 700;
  font-size: var(--text-base);
}

.drawer__email {
  font-size: var(--text-xs);
  color: #9CA3AF;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer__header .modal__close {
  color: rgba(255, 255, 255, 0.7);
}

.drawer__header .modal__close:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--color-text-inverse);
}

.drawer__menu {
  display: flex;
  flex-direction: column;
  padding: var(--space-3);
  gap: 2px;
}

.drawer__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 12px var(--space-3);
  border-radius: var(--radius-md);
  background: none;
  border: none;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-secondary);
  text-align: left;
  width: 100%;
}

.drawer__item:hover {
  background: var(--color-surface-muted);
}

.drawer__item--danger {
  color: var(--color-danger);
}

.drawer__item-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.drawer__item-label {
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--color-text-faint);
}

.drawer__footer {
  margin-top: auto;
  padding: var(--space-3);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Indicador de conectividade real com a API (ver accountDrawer.js checkApiHealth) — não é
   decorativo. Mesma altura/padding de .drawer__item para alinhar visualmente com os botões
   logo abaixo, mas sem hover/clique: não é uma ação. */
.drawer__api-status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 8px var(--space-3);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-muted);
}

.drawer__api-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
  background: var(--color-text-faint);
  transition: background-color 150ms ease;
}

.drawer__api-status[data-api-status="online"] .drawer__api-dot {
  background: var(--color-success);
  box-shadow: 0 0 0 3px var(--color-success-light);
}

.drawer__api-status[data-api-status="offline"] .drawer__api-dot {
  background: var(--color-danger);
  box-shadow: 0 0 0 3px var(--color-danger-light);
}

.drawer__api-status[data-api-status="checking"] .drawer__api-dot {
  animation: drawer-api-pulse 1.2s ease-in-out infinite;
}

@keyframes drawer-api-pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* ---------- Loading ---------- */
.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  display: inline-block;
  animation: spin 0.7s linear infinite;
}

.loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-8) 0;
  color: var(--color-text-muted);
  font-size: var(--text-sm);
}

.loading-row .spinner {
  border-color: var(--color-border-strong);
  border-top-color: var(--color-primary);
}

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

/* ---------- Auth / gate brand lockup (login, CS-selection) ---------- */
.auth-shell {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: var(--space-8);
}

.auth-brand__logo {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-xl);
  margin-bottom: var(--space-3);
}

/* The "e" glyph (frontend/icons/logo-e.png, pre-recolored to white-on-transparent — see the
   image itself, not CSS, for its color) drawn as a plain <img>, deliberately not a CSS mask-image
   painted via `background: currentColor`: that approach — otherwise the nicer one, no separate
   white-only asset needed — rendered as a blank box in this app's target browser, seemingly
   regardless of the source's color or pixel size (tried both up to 1080×1080 and back down to
   128×128; a plain <img> with the same file rendered correctly at every size tried). If a
   from-scratch redo of this ever revisits mask-image, verify it actually paints something first. */
.brand-logo__glyph {
  width: 62%;
  height: 62%;
  object-fit: contain;
}

.auth-brand__title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.auth-brand__title small {
  font-weight: 500;
  color: var(--color-text-muted);
}

.auth-brand__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.gate-title {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text);
  text-align: center;
}

.gate-subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  text-align: center;
  margin-top: 4px;
  margin-bottom: var(--space-6);
}

/* ---------- Login card ---------- */
.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: var(--space-6);
}

.auth-card__title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.auth-card__desc {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: 4px;
  margin-bottom: var(--space-5);
}

.auth-error {
  background: var(--color-danger-light);
  border: 1px solid var(--color-danger);
  color: var(--color-danger);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
}

/* ---------- CS-selection grid ---------- */
/* Flex-wrap (not CSS grid) so incomplete rows center instead of hugging the
   left edge — a lone card (or any partial last row) lands in the middle,
   matching a full row's alignment instead of looking stranded. Card width is a
   fraction of the row, so fewer-than-max cards per row simply center rather
   than stretch. Um por linha até 620px, dois até 1280px, três acima — os
   mesmos pontos de quebra de .card-grid, para o CS parecer com o resto do app. */
.cs-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-4);
  width: 100%;
}

.cs-grid .cs-card {
  flex: 0 0 100%;
}

@media (min-width: 620px) {
  .cs-grid .cs-card {
    flex: 0 0 calc((100% - var(--space-4)) / 2);
  }
}

@media (min-width: 1280px) {
  .cs-grid .cs-card {
    flex: 0 0 calc((100% - 2 * var(--space-4)) / 3);
  }
}

/* Card deitado (ícone à esquerda, nome à direita), como .epi-card faz no
   resto do app — a versão em pé de .cs-card ficava mais alta do que
   larga assim que uma razão social quebrava em três linhas, que é o caso comum
   ("Syngenta Proteção de Cultivos LTDA"). Só dentro de .cs-grid: o menu do hub
   (.hub-card) continua em pé, porque ali cada card tem descrição embaixo. */
.cs-grid .cs-card {
  flex-direction: row;
  align-items: center;
  gap: var(--space-4);
  text-align: left;
  padding: var(--space-4) var(--space-5);
  min-height: 92px;
}

.cs-grid .cs-card__icon {
  flex: none;
}

.cs-grid .cs-card__name {
  min-width: 0;
}

/* ---------- Hub menu grid (post-CS) — independent of .cs-grid: always
   exactly 3 destinations, so a plain CSS grid (no centering trick needed)
   that caps at 3 columns instead of following CS-selection up to 4. ---------- */
.hub-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-4);
  width: 100%;
}

@media (min-width: 620px) {
  .hub-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 980px) {
  .hub-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1280px) {
  .hub-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 900px;
  }
}

.cs-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-4);
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.cs-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

/* ---------- Hub menu (post-CS) — richer variant of .cs-card/.cs-grid ---------- */
.hub-shell {
  width: 100%;
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: var(--space-4) 0 var(--space-2);
}

.hub-kicker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: var(--space-3);
}

.hub-kicker__icon {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.hub-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  margin-bottom: var(--space-8);
}

.hub-card {
  padding: var(--space-8) var(--space-5);
}

.hub-card:hover {
  transform: translateY(-3px);
}

.hub-card__icon {
  width: 60px;
  height: 60px;
}

.hub-card__desc {
  font-size: var(--text-xs);
  font-weight: 400;
  line-height: 1.5;
  color: var(--color-text-muted);
}

.hub-pending {
  width: 100%;
  max-width: 900px;
  margin: var(--space-8) auto 0;
}

.hub-pending__title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text);
  margin-bottom: var(--space-4);
}

.hub-pending__title svg {
  color: var(--color-warning);
}

/* Minimal "go to" affordance for a clickable table row (see menuScreen.js's pending-lotes list) —
   a plain arrow instead of a labeled button. */
.row-arrow-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-primary);
  transition: border-color 0.15s ease, background 0.15s ease;
}

.row-arrow-btn:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-light);
}

.cs-card__icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  background: var(--color-primary-light);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.cs-card__name {
  font-weight: 700;
  font-size: var(--text-base);
  color: var(--color-text);
  line-height: 1.3;
}

/* ---------- Editar Itens modal (per-employee item list) ---------- */
.modal-item-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.modal-item-row {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.modal-item-row__name {
  font-weight: 700;
  font-size: var(--text-sm);
  color: var(--color-text);
}

.modal-item-row__meta {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: 2px;
  margin-bottom: var(--space-3);
}

.modal-item-row__controls {
  display: grid;
  grid-template-columns: 84px 1fr auto;
  gap: var(--space-2);
  align-items: end;
}

.modal-item-row__remove {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-danger-light);
  background: var(--color-danger-light);
  color: var(--color-danger);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.modal-item-row__remove:hover {
  background: var(--color-danger);
  color: var(--color-text-inverse);
}

.modal-add-item {
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-top: var(--space-3);
}

@media (max-width: 360px) {
  .modal-item-row__controls {
    grid-template-columns: 1fr;
  }

  .modal-item-row__remove {
    width: 100%;
    gap: 6px;
  }

  .modal-item-row__remove::after {
    content: "Remover";
    font-size: var(--text-xs);
    font-weight: 600;
  }
}

/* ---------- Verificação de assinatura (tela Admin) ---------- */
.verify-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  align-items: flex-end;
  margin-bottom: var(--space-5);
}

.verify-form__actions {
  display: flex;
  gap: var(--space-2);
}

/* Hash é hexadecimal de 64 caracteres: monoespaçado e com um leve espaçamento, para conferir
   caractere por caractere contra o PDF sem confundir 0/O ou 1/I. */
.verify-form__hash {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  letter-spacing: 0.02em;
}

.verify-result {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  margin-bottom: var(--space-6);
}

.verify-result--valid {
  background: var(--color-success-light);
  border-color: var(--color-success-border);
}

.verify-result--invalid {
  background: var(--color-danger-light);
  border-color: var(--color-danger);
}

.verify-result__head {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.verify-result__icon {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
}

.verify-result__icon--valid {
  color: var(--color-success);
}

.verify-result__icon--invalid {
  color: var(--color-danger);
}

.verify-result__title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--color-text);
}

.verify-result__desc {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* O hash inteiro fica visível (nunca truncado com "…") — é o dado que a pessoa está conferindo.
   Quebra em qualquer caractere porque são 64 sem um único espaço. */
.verify-result__hash {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  overflow-wrap: anywhere;
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

/* Lista rótulo/valor de duas colunas que colapsa para uma só no estreito. */
.kv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-3) var(--space-6);
  margin: 0;
}

.kv-grid__row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.kv-grid__label {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.kv-grid__value {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
  overflow-wrap: anywhere;
}

.kv-grid__note {
  display: flex;
  gap: 6px;
  align-items: flex-start;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin: var(--space-3) 0 0;
}

.kv-grid__note svg {
  flex: none;
  margin-top: 2px;
}

/* .table-wrap nao tem margem propria (quem separa as secoes desta tela e o margin-bottom do
   .review-panel), e .review-section-title so define margin-bottom — sem isto o titulo da secao
   seguinte cola na tabela de EPIs. */
.verify-itens {
  margin-bottom: var(--space-6);
}

.verify-photo {
  display: flex;
  justify-content: center;
}

/* A miniatura e um botao: clicar abre a foto ampliada no modal padrao (ver abrirFotoAmpliada). */
.verify-photo__btn {
  background: none;
  border: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  cursor: zoom-in;
}

.verify-photo__img {
  max-width: 320px;
  width: 100%;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
  display: block;
  transition: border-color 120ms ease;
}

.verify-photo__btn:hover .verify-photo__img,
.verify-photo__btn:focus-visible .verify-photo__img {
  border-color: var(--color-primary);
}

.verify-photo__hint {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

/* Mais largo que o modal de formulario (520px), que e estreito demais para uma foto. */
.modal--foto {
  max-width: 720px;
}

.verify-photo__ampliada {
  width: 100%;
  border-radius: var(--radius-md);
  display: block;
}

/* A linha da tabela correspondente ao hash consultado — as outras foram assinadas no mesmo ato,
   cada uma com o seu proprio hash. */
.verify-item-row--atual > td {
  background: var(--color-success-light);
}

/* Miniatura clicável dentro de uma célula de tabela (ver fotosSuspeitasScreen.js) — mesma ideia
   de .verify-photo__btn, só que pequena o bastante para caber numa linha em vez de ocupar o
   painel inteiro. */
.auditoria-foto-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: zoom-in;
  display: block;
}

.auditoria-foto-btn__img {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  display: block;
  transition: border-color 120ms ease;
}

.auditoria-foto-btn:hover .auditoria-foto-btn__img,
.auditoria-foto-btn:focus-visible .auditoria-foto-btn__img {
  border-color: var(--color-primary);
}

/* ---------- Tela de sincronização (gate, ocupa a janela inteira) ----------
   Componente visual único de toda sincronização do app — o "Sincronizar Tudo" do menu e os
   botões pontuais (CS, EPIs, funcionários) caem todos aqui. Ver sincronizacaoScreen.js. */
.sync-shell {
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--space-4);
}

.sync-brand {
  margin-bottom: var(--space-2);
}

.sync-title {
  font-size: var(--text-xl);
  font-weight: 800;
  color: var(--color-text);
  /* Os três pontos animados ficam fora do fluxo do texto: sem isto, o título "pula" na
     horizontal a cada ponto que aparece. */
  display: inline-flex;
  align-items: baseline;
}

.sync-dots {
  display: inline-flex;
  width: 1.4em;
}

.sync-dots span {
  opacity: 0;
  animation: sync-dot 1.2s infinite;
}

.sync-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.sync-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes sync-dot {
  0%,
  60%,
  100% {
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
}

/* Respeita quem pediu menos movimento no sistema — os pontos viram estáticos em vez de sumirem,
   para o título não ficar cortado. */
@media (prefers-reduced-motion: reduce) {
  .sync-dots span {
    animation: none;
    opacity: 1;
  }
}

.sync-bar {
  width: 100%;
  height: 8px;
  border-radius: 999px;
  background: var(--color-border);
  overflow: hidden;
}

.sync-bar__fill {
  height: 100%;
  border-radius: 999px;
  background: var(--color-primary);
  transition: width 0.35s ease;
}

.sync-status {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.5;
}

.sync-status--muted {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: calc(var(--space-3) * -1);
}

.sync-cancel {
  margin-top: var(--space-6);
}

/* Texto corrido dentro de um modal de confirmação (sem formulário). */
.modal-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  line-height: 1.6;
}

/* Botão de sincronizar embutido numa tela (etapa de EPIs/funcionários, seleção de CS) — discreto
   ao lado dos filtros, não competindo com a ação principal da tela. */
.sync-inline-btn {
  white-space: nowrap;
}

/* ---------- Ações da tela de seleção de CS ---------- */
/* Fixo no canto superior direito da janela (a tela de seleção de CS é um "gate", sem header —
   ver app.js GATE_MODULES — então não há barra superior para hospedar isto; fica ancorado na
   mesma posição que um ícone de header ocuparia, fora do fluxo do conteúdo centralizado). */
.cs-actions {
  position: fixed;
  top: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-header);
}

/* ---------- Cartão de supervisor (etapa "Supervisor" do wizard) ----------
   Mesmo formato deitado dos cartões de CS — ícone à esquerda, texto à direita —
   porque a decisão aqui é da mesma natureza: escolher um item de uma lista curta. */
.supervisor-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  text-align: left;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.supervisor-card:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.supervisor-card[data-selected="true"] {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 1px var(--color-primary);
  background: var(--color-primary-light);
}

/* A opção "Todos" fica fora da grade e antes dela: é a exceção, não mais um
   supervisor da lista. */
.supervisor-card--todos {
  margin-bottom: var(--space-4);
}

.supervisor-card__texto {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.supervisor-card__nome {
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.supervisor-card__meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  line-height: 1.4;
}

.supervisor-card__check {
  flex: none;
  color: var(--color-primary);
  display: flex;
}

/* ---------- Compactação geral em mobile/tablet ---------- */
@media (max-width: 1024px) {
  .step-card {
    padding: var(--space-4);
  }

  .step-card__top {
    gap: var(--space-3);
    margin-bottom: var(--space-4);
  }

  .btn {
    padding: 8px 12px;
  }

  .btn--sm {
    padding: 5px 9px;
  }

  .cs-card,
  .supervisor-card {
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
  }

  .cs-grid .cs-card {
    min-height: 76px;
  }

  .cs-card__icon {
    width: 42px;
    height: 42px;
  }

  .hub-card {
    padding: var(--space-5) var(--space-4);
  }

  .hub-card__icon {
    width: 44px;
    height: 44px;
  }

  .hub-title {
    margin-bottom: var(--space-5);
  }

  .hub-kicker {
    margin-bottom: var(--space-2);
  }
}
