/* Tela de login (templates/login.html). Cores da marca de style.css;
   tema claro/escuro pelo sistema; só transform/opacity/filter animam. */
.lg-html {
  --lg-bg: var(--na-cream);
  --lg-card: #fff;
  --lg-ink: var(--ink);
  --lg-soft: #5b6475;
  --lg-line: #e3e7ee;
  --lg-campo: #f8fafc;
  --lg-foco: var(--na-blue);
  --lg-erro: #c81e1e;
  --lg-erro-bg: #fef2f2;
  --lg-ok: #15803d;
  --lg-sombra: 0 24px 60px rgba(13, 127, 184, 0.16);
  --lg-ease: cubic-bezier(0.22, 1, 0.36, 1);
  color-scheme: light;
}
/* tema escuro: o mesmo escolhido em Aparência (guardado neste aparelho);
   sem escolha guardada a tela abre sempre no claro */
.lg-html[data-lg-tema="escuro"] {
    --lg-bg: #0b1220;
    --lg-card: #131c2e;
    --lg-ink: #f1f5f9;
    --lg-soft: #a3b0c4;
    --lg-line: #2a3650;
    --lg-campo: #0f1727;
    --lg-foco: #4cc3f2;
    --lg-erro: #fca5a5;
    --lg-erro-bg: #3b1219;
    --lg-ok: #4ade80;
    --lg-sombra: 0 24px 60px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
}

/* botão claro/escuro no canto */
.lg-tema {
  position: fixed;
  top: max(0.8rem, env(safe-area-inset-top));
  right: 0.8rem;
  z-index: 5;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  border: 1px solid var(--lg-line);
  background: var(--lg-card);
  color: var(--lg-ink);
  font-size: 1.15rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  transition: transform 0.16s var(--lg-ease);
}
.lg-tema:hover {
  transform: scale(1.06);
}
.lg-tema:focus-visible {
  outline: 3px solid var(--lg-foco);
  outline-offset: 2px;
}

.lg-body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--lg-bg);
  color: var(--lg-ink);
  display: block;
}
main.lg {
  padding: 0;
  margin: 0;
  max-width: none;
  width: 100%;
}
.lg {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
}

/* ---------- painel da marca ---------- */
.lg-marca {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #fff;
  background: linear-gradient(150deg, #0d7fb8 0%, var(--na-blue) 55%, #46c1ee 100%);
}
.lg-marca-conteudo {
  position: relative;
  max-width: 440px;
  animation: lg-subir 0.5s var(--lg-ease) both;
}
.lg-marca-logo {
  width: 100%;
  max-width: 340px;
  height: auto;
  background: #fff;
  border-radius: 20px;
  padding: 1rem 1.4rem;
  box-shadow: 0 18px 40px rgba(0, 40, 80, 0.25);
}
.lg-frase {
  font-size: 1.55rem;
  line-height: 1.3;
  font-weight: 700;
  margin: 1.6rem 0 1rem;
}
.lg-pontos {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.55rem;
  font-size: 1rem;
  opacity: 0.95;
}
.lg-pontos li {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  width: fit-content;
}
.lg-bolhas span {
  position: absolute;
  border-radius: 50%;
  filter: blur(2px);
  opacity: 0.55;
  will-change: transform;
}
.lg-bolhas span:nth-child(1) {
  width: 420px;
  height: 420px;
  left: -140px;
  top: -120px;
  background: radial-gradient(circle, rgba(255, 210, 0, 0.55), transparent 65%);
  animation: lg-flutuar 18s ease-in-out infinite alternate;
}
.lg-bolhas span:nth-child(2) {
  width: 520px;
  height: 520px;
  right: -200px;
  bottom: -220px;
  background: radial-gradient(circle, rgba(247, 148, 29, 0.6), transparent 65%);
  animation: lg-flutuar 22s ease-in-out -6s infinite alternate-reverse;
}
.lg-bolhas span:nth-child(3) {
  width: 260px;
  height: 260px;
  right: 18%;
  top: 12%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.45), transparent 65%);
  animation: lg-flutuar 16s ease-in-out -3s infinite alternate;
}

/* ---------- painel do formulário ---------- */
.lg-painel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;
}
.lg-cartao {
  width: 100%;
  max-width: 400px;
  background: var(--lg-card);
  border: 1px solid var(--lg-line);
  border-radius: 20px;
  padding: 2.2rem 2rem;
  box-shadow: var(--lg-sombra);
  animation: lg-subir 0.4s var(--lg-ease) both;
}
.lg-logo-celular {
  display: none;
}
.lg-titulo {
  font-size: 1.6rem;
  margin: 0 0 0.25rem;
  color: var(--lg-ink);
  border: 0;
}
.lg-sub {
  margin: 0 0 1.4rem;
  color: var(--lg-soft);
  font-size: 0.95rem;
}
.lg-rodape {
  margin: 1.2rem 0 0;
  font-size: 0.78rem;
  color: var(--lg-soft);
}

/* avisos do servidor e do envio */
.lg-aviso {
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  margin: 0 0 1rem;
  font-size: 0.92rem;
  font-weight: 500;
  border: 1px solid transparent;
  animation: lg-subir 0.25s var(--lg-ease) both;
}
.lg-aviso[hidden] {
  display: none;
}
.lg-aviso-error {
  background: var(--lg-erro-bg);
  color: var(--lg-erro);
  border-color: color-mix(in srgb, var(--lg-erro) 35%, transparent);
}
.lg-aviso-info,
.lg-aviso-message {
  background: color-mix(in srgb, var(--lg-foco) 12%, transparent);
  color: var(--lg-ink);
  border-color: color-mix(in srgb, var(--lg-foco) 35%, transparent);
}

/* campos com rótulo flutuante */
.lg-campo {
  position: relative;
  margin: 0 0 1rem;
}
.lg-campo input {
  width: 100%;
  font: inherit;
  font-size: 1rem; /* ≥16px: o iPhone não dá zoom ao focar */
  color: var(--lg-ink);
  background: var(--lg-campo);
  border: 1.5px solid var(--lg-line);
  border-radius: 12px;
  padding: 1.35rem 0.95rem 0.5rem;
  min-height: 3.4rem;
  outline: none;
  transition:
    border-color 0.18s var(--lg-ease),
    box-shadow 0.18s var(--lg-ease),
    background-color 0.18s var(--lg-ease);
}
.lg-campo label {
  position: absolute;
  left: 0.95rem;
  top: 1.05rem;
  color: var(--lg-soft);
  pointer-events: none;
  transform-origin: left top;
  transition:
    transform 0.18s var(--lg-ease),
    color 0.18s var(--lg-ease);
}
.lg-campo input:focus + label,
.lg-campo input:not(:placeholder-shown) + label,
.lg-campo input:-webkit-autofill + label {
  transform: translateY(-0.62rem) scale(0.78);
}
.lg-campo input:focus {
  border-color: var(--lg-foco);
  background: var(--lg-card);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--lg-foco) 22%, transparent);
}
.lg-campo input:focus + label {
  color: var(--lg-foco);
}
/* preenchimento automático do navegador: mantém as cores do tema (claro/escuro) */
.lg-campo input:-webkit-autofill,
.lg-campo input:-webkit-autofill:hover,
.lg-campo input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--lg-ink);
  caret-color: var(--lg-ink);
  -webkit-box-shadow: 0 0 0 100px var(--lg-campo) inset;
  transition: background-color 9999s;
}
.lg-campo-senha input {
  padding-right: 3.2rem;
}
.lg-campo-codigo input {
  font-size: 1.5rem;
  letter-spacing: 0.45rem;
  font-variant-numeric: tabular-nums;
}
.lg-invalido input {
  border-color: var(--lg-erro);
}
.lg-invalido input:focus {
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--lg-erro) 22%, transparent);
}
.lg-invalido label {
  color: var(--lg-erro);
}
.lg-msg {
  margin: 0.3rem 0 0 0.2rem;
  font-size: 0.83rem;
  color: var(--lg-erro);
  min-height: 0;
}
.lg-msg:empty {
  display: none;
}
.lg-caps {
  margin: 0.3rem 0 0 0.2rem;
  font-size: 0.83rem;
  color: var(--warn);
  font-weight: 600;
}

/* mostrar/ocultar senha */
.lg-olho {
  position: absolute;
  right: 0.35rem;
  top: 0.35rem;
  width: 2.7rem;
  height: 2.7rem;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--lg-soft);
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
  box-shadow: none;
}
.lg-olho svg {
  width: 1.3rem;
  height: 1.3rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lg-olho:hover {
  color: var(--lg-ink);
  background: color-mix(in srgb, var(--lg-soft) 12%, transparent);
  transform: none;
}
.lg-olho-fechado,
.lg-olho[aria-pressed="true"] .lg-olho-aberto {
  display: none;
}
.lg-olho[aria-pressed="true"] .lg-olho-fechado {
  display: block;
}

/* botão principal */
.lg-acoes {
  margin-top: 0.4rem;
}
.lg-btn {
  position: relative;
  width: 100%;
  min-height: 3.2rem;
  border: 0;
  border-radius: 12px;
  font: inherit;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--na-blue) 0%, var(--na-blue-dark) 100%);
  box-shadow: 0 8px 20px rgba(27, 166, 224, 0.35);
  transition:
    transform 0.16s var(--lg-ease),
    box-shadow 0.16s var(--lg-ease),
    filter 0.16s var(--lg-ease);
}
.lg-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}
.lg-btn:active {
  transform: scale(0.98);
}
.lg-btn:disabled {
  cursor: progress;
}
.lg-spin,
.lg-ok {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1.4rem;
  height: 1.4rem;
  margin: -0.7rem 0 0 -0.7rem;
  opacity: 0;
}
.lg-spin {
  border-radius: 50%;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
}
.lg-ok {
  fill: none;
  stroke: #fff;
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transform: scale(0.6);
}
.lg-btn-txt {
  display: inline-block;
  transition:
    opacity 0.15s var(--lg-ease),
    transform 0.15s var(--lg-ease);
}
.lg-carregando .lg-btn-txt,
.lg-sucesso .lg-btn-txt {
  opacity: 0;
  transform: translateY(-4px);
}
.lg-carregando .lg-spin {
  opacity: 1;
  animation: lg-girar 0.7s linear infinite;
}
.lg-sucesso {
  background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.35);
}
.lg-sucesso .lg-ok {
  opacity: 1;
  transform: scale(1);
  transition:
    opacity 0.2s var(--lg-ease),
    transform 0.25s var(--lg-ease);
}
.lg-voltar {
  display: block;
  text-align: center;
  margin-top: 0.9rem;
  color: var(--lg-soft);
}

/* crachá (quando ligado) */
.lg-cracha {
  margin-top: 1.2rem;
  border-top: 1px solid var(--lg-line);
  padding-top: 0.9rem;
}
.lg-cracha summary {
  cursor: pointer;
  color: var(--lg-soft);
  font-weight: 600;
  margin-bottom: 0.8rem;
}
.lg-btn-sec {
  width: 100%;
  min-height: 2.8rem;
  border-radius: 12px;
  border: 1.5px solid var(--lg-line);
  background: transparent;
  color: var(--lg-ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
#loginScanVideo {
  width: 100%;
  border-radius: 12px;
  background: #000;
  margin-top: 0.6rem;
}
@media (hover: hover) and (pointer: fine) {
  #loginScanBtn {
    display: none; /* no computador o crachá vem do leitor físico */
  }
}

/* foco visível por teclado */
.lg-btn:focus-visible,
.lg-btn-sec:focus-visible,
.lg-olho:focus-visible,
.lg-cracha summary:focus-visible,
.lg-voltar:focus-visible {
  outline: 3px solid var(--lg-foco);
  outline-offset: 2px;
}

/* resultado */
.lg-tremer {
  animation: lg-tremer 0.36s var(--lg-ease);
}
.lg-entrar {
  animation: lg-subir 0.3s var(--lg-ease) both;
}
.lg-entrou {
  transition:
    opacity 0.3s var(--lg-ease) 0.12s,
    transform 0.3s var(--lg-ease) 0.12s,
    filter 0.3s var(--lg-ease) 0.12s;
  opacity: 0;
  transform: translateY(-6px) scale(0.99);
  filter: blur(2px);
}

@keyframes lg-subir {
  from {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(3px);
  }
  to {
    opacity: 1;
    transform: none;
    filter: none;
  }
}
@keyframes lg-tremer {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-8px);
  }
  40% {
    transform: translateX(7px);
  }
  60% {
    transform: translateX(-5px);
  }
  80% {
    transform: translateX(3px);
  }
}
@keyframes lg-girar {
  to {
    transform: rotate(360deg);
  }
}
@keyframes lg-flutuar {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(40px, 30px, 0) scale(1.08);
  }
}

/* ---------- celular: uma coluna, botão ao alcance do polegar ---------- */
@media (max-width: 860px) {
  .lg {
    grid-template-columns: 1fr;
  }
  .lg-marca {
    display: none;
  }
  .lg-painel {
    justify-content: flex-start;
    padding: max(1.2rem, env(safe-area-inset-top)) 1rem 0;
    background:
      radial-gradient(120% 60% at 50% -10%, color-mix(in srgb, var(--na-blue) 22%, transparent), transparent 70%),
      var(--lg-bg);
  }
  .lg-cartao {
    max-width: 480px;
    padding: 1.4rem 1.2rem 0;
    border-radius: 20px 20px 0 0;
    box-shadow: none;
    border-bottom: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  .lg-logo-celular {
    display: block;
    width: 170px;
    height: auto;
    margin: 0 auto 1rem;
  }
  .lg-titulo {
    font-size: 1.45rem;
  }
  .lg-form {
    flex: 1;
    display: flex;
    flex-direction: column;
  }
  .lg-acoes {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding: 0.8rem 0 max(1rem, env(safe-area-inset-bottom));
    background: linear-gradient(to top, var(--lg-card) 75%, transparent);
  }
  .lg-btn {
    min-height: 3.5rem;
  }
  .lg-rodape {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .lg-bolhas span,
  .lg-marca-conteudo,
  .lg-cartao,
  .lg-aviso,
  .lg-tremer,
  .lg-entrar {
    animation: none !important;
  }
  .lg-entrou {
    transition: none;
  }
  .lg-carregando .lg-spin {
    animation-duration: 1.6s;
  }
}
