/* =========================================================================
   BuxBox — Design System
   -------------------------------------------------------------------------
   Paleta "aço + sinal de leitura": nada de creme/terracota nem preto/neon
   genéricos. O produto vive em dois contextos: um totem fixo perto de uma
   porta (device.html, tema escuro, alto contraste, legível de longe) e
   painéis de gestão (claro, denso, para uso prolongado em escritório).

   Assinatura visual: o "retículo de leitura" — cantos de mira em L que
   emolduram a câmera/estado de processamento — reaparece em toda a suíte
   como o motivo de "capturando/validando".
   ========================================================================= */

:root {
  /* Cor */
  --ink: #171b1f;
  --steel-700: #2b3138;
  --steel-500: #4a525c;
  --steel-300: #8b939c;
  --line: #d8dcdd;
  --paper: #eef1f0;
  --surface: #ffffff;
  --surface-sunken: #e4e8e7;

  --signal: #1f9c92;       /* leitura em andamento / confirmado */
  --signal-dim: #16736b;
  --amber: #d98c2b;        /* espera / pendente */
  --danger: #bd4438;       /* falha / bloqueado */
  --success: #2f8f5b;      /* homologado / ok */

  /* Kiosk (device.html) */
  --kiosk-bg: #14181c;
  --kiosk-bg-raised: #1c2126;
  --kiosk-text: #eef1f0;
  --kiosk-text-dim: #8b939c;

  /* Tipografia */
  --font-mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Escala */
  --radius-sm: 3px;
  --radius-md: 6px;
  --radius-lg: 14px;
  --shadow-card: 0 1px 2px rgba(23, 27, 31, 0.06), 0 8px 24px -12px rgba(23, 27, 31, 0.18);
}

* { box-sizing: border-box; }
html { color-scheme: light; }

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

a { color: inherit; }

/* --------------------------- Tipografia utilitária --------------------- */
.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--steel-300);
}

/* ------------------------------- Botões --------------------------------- */
.btn {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background-color 120ms ease, border-color 120ms ease, transform 80ms ease;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

.btn-primary { background: var(--ink); color: var(--surface); }
.btn-primary:hover { background: var(--steel-700); }

.btn-signal { background: var(--signal); color: #fff; }
.btn-signal:hover { background: var(--signal-dim); }

.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn-ghost:hover { background: var(--surface-sunken); }

.btn-danger { background: transparent; color: var(--danger); border-color: rgba(189, 68, 56, 0.35); }
.btn-danger:hover { background: rgba(189, 68, 56, 0.08); }

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* -------------------------------- Campos -------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; font-weight: 600; color: var(--steel-500); }
.field input, .field select, .field textarea {
  font-family: var(--font-sans);
  font-size: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
  border-color: var(--signal);
}

/* -------------------------------- Cartões ------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: 20px; }

/* -------------------------------- Selos --------------------------------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-mono);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-signal { background: rgba(31, 156, 146, 0.12); color: var(--signal-dim); }
.pill-amber { background: rgba(217, 140, 43, 0.14); color: #8a5a15; }
.pill-danger { background: rgba(189, 68, 56, 0.12); color: var(--danger); }
.pill-success { background: rgba(47, 143, 91, 0.12); color: var(--success); }
.pill-neutral { background: var(--surface-sunken); color: var(--steel-500); }

/* --------------------------- Retículo de leitura -------------------------
   Assinatura visual: quatro cantos em L, como uma mira de scanner.
   Usado ao redor da câmera (device.html) e em qualquer estado de
   "processando/validando" nos painéis administrativos.
   ------------------------------------------------------------------------- */
.reticle {
  position: relative;
  display: inline-block;
}
.reticle::before, .reticle::after,
.reticle .rc-tl, .reticle .rc-tr, .reticle .rc-bl, .reticle .rc-br {
  content: '';
  position: absolute;
  width: 22px;
  height: 22px;
  border: 2px solid var(--signal);
  opacity: 0.85;
}
.reticle .rc-tl { top: -8px; left: -8px; border-right: none; border-bottom: none; border-top-left-radius: 6px; }
.reticle .rc-tr { top: -8px; right: -8px; border-left: none; border-bottom: none; border-top-right-radius: 6px; }
.reticle .rc-bl { bottom: -8px; left: -8px; border-right: none; border-top: none; border-bottom-left-radius: 6px; }
.reticle .rc-br { bottom: -8px; right: -8px; border-left: none; border-top: none; border-bottom-right-radius: 6px; }
.reticle::before, .reticle::after { content: none; }

.reticle.is-scanning .rc-tl,
.reticle.is-scanning .rc-tr,
.reticle.is-scanning .rc-bl,
.reticle.is-scanning .rc-br {
  animation: reticle-pulse 1.4s ease-in-out infinite;
}
.reticle.is-ok .rc-tl, .reticle.is-ok .rc-tr, .reticle.is-ok .rc-bl, .reticle.is-ok .rc-br { border-color: var(--success); }
.reticle.is-error .rc-tl, .reticle.is-error .rc-tr, .reticle.is-error .rc-bl, .reticle.is-error .rc-br { border-color: var(--danger); }

@keyframes reticle-pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.08); opacity: 1; }
}

/* ------------------------------- Tabelas -------------------------------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--steel-300); font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line); }
td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: var(--surface-sunken); }

/* Cartão de tabela: quando a lista excede a altura disponível, rola por
   dentro do card com o cabeçalho acompanhando o scroll. */
.table-card { max-height: 65vh; overflow: auto; }
.table-card table { border-collapse: separate; border-spacing: 0; }
.table-card thead th {
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

/* Ferramentas de tabela: busca livre + filtros + cabeçalhos ordenáveis */
.table-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.table-search { margin-bottom: 12px; max-width: 320px; }
.table-tools .table-search { margin-bottom: 0; flex: 1 1 240px; }
.table-search input {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 13.5px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.table-search input:focus {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
  border-color: var(--signal);
}
.table-tools select {
  font-family: var(--font-sans);
  font-size: 13.5px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}
.table-tools select:focus {
  outline: 2px solid var(--signal);
  outline-offset: 1px;
  border-color: var(--signal);
}

th[data-key] { cursor: pointer; user-select: none; }
th[data-key]:hover { color: var(--steel-500); }
th[data-key]::after { content: ''; display: inline-block; width: 10px; }
th[data-key].th-asc::after { content: '▲'; font-size: 9px; color: var(--signal); }
th[data-key].th-desc::after { content: '▼'; font-size: 9px; color: var(--signal); }

/* ------------------------------- Shell de painel ------------------------- */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.shell-nav {
  background: var(--ink);
  color: var(--paper);
  padding: 24px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.shell-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px 20px; }
.shell-brand svg { flex-shrink: 0; }
.shell-brand-name { font-weight: 700; letter-spacing: 0.01em; font-size: 15px; }
.shell-brand-sub { font-family: var(--font-mono); font-size: 10.5px; color: var(--steel-300); letter-spacing: 0.08em; text-transform: uppercase; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(238, 241, 240, 0.72);
  cursor: pointer;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
}
.nav-item:hover { background: rgba(238, 241, 240, 0.06); color: #fff; }
.nav-item.active { background: rgba(31, 156, 146, 0.16); color: #fff; }

.shell-main { padding: 28px 36px 60px; max-width: 1180px; }
.shell-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 28px; }
.shell-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.shell-subtitle { color: var(--steel-500); font-size: 13.5px; margin-top: 2px; }

.section { margin-bottom: 32px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.section-head h2 { font-size: 15px; margin: 0; }

.grid-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.stat-card { padding: 16px 18px; }
.stat-value { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: -0.01em; }
.stat-label { font-size: 12px; color: var(--steel-500); margin-top: 4px; }

.empty-state { padding: 40px 20px; text-align: center; color: var(--steel-500); font-size: 13.5px; }
.toast {
  position: fixed; bottom: 20px; right: 20px; z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: var(--radius-md);
  font-size: 13.5px; box-shadow: var(--shadow-card); max-width: 320px;
}
.toast.error { background: var(--danger); }
.toast.success { background: var(--success); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .shell-nav { flex-direction: row; overflow-x: auto; overflow-y: visible; padding: 12px; height: auto; }
  .shell-brand { display: none; }
  .shell-main { padding: 20px; }
}

/* Utilitário para esconder elementos (usado pelas telas administrativas -
   admin.html, empresa.html, funcionario.html, index.html). Já existia em
   device.css, mas faltava aqui. */
.hidden { display: none !important; }
