/* auth central — tela de login no padrão §2, cor da marca: esmeralda.
   Tudo em CSS puro; dark é o padrão, claro via :root[data-theme="light"]. */

:root {
  --bg: #0b0d14;
  --surface: #151823;
  --surface-2: #1b1f2c;
  --border: #2a3042;
  --text: #e9ebf2;
  --muted: #8d95aa;
  --danger: #ef4444;
  --danger-text: #f87171;
  --success: #22c55e;
  --primaria: #10b981;
  --primaria-2: #14b8a6;
  --primaria-3: #06b6d4;
  --radius: 10px;
}
:root[data-theme="light"] {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface-2: #e7ebf3;
  --border: #d3d9e5;
  --text: #1d2436;
  --muted: #5f6880;
  --danger-text: #dc2626;
  --success: #15803d;
}

* { box-sizing: border-box; }
/* Sem isto, qualquer display: definido em classe (ex.: .cartao flex) vence o
   atributo hidden e os dois cartões aparecem juntos — já aconteceu */
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  /* Sem isto o navegador pinta fundo branco no overscroll — já aconteceu */
  background: var(--bg);
  color: var(--text);
}

/* ===== Fundo: auroras + grade pontilhada (§2) ===== */

.fundo { position: fixed; inset: 0; overflow: hidden; z-index: 0; }
.aurora {
  position: absolute;
  width: 55vmax; height: 55vmax;
  border-radius: 50%;
  filter: blur(90px);
  opacity: .5;
}
:root[data-theme="light"] .aurora { opacity: .25; }
.a1 { background: var(--primaria);  top: -20vmax; left: -12vmax; animation: drift 26s ease-in-out -4s infinite alternate; }
.a2 { background: var(--primaria-3); bottom: -22vmax; right: -14vmax; animation: drift 32s ease-in-out -12s infinite alternate; }
.a3 { background: var(--primaria-2); top: 30%; left: 55%; width: 38vmax; height: 38vmax; animation: drift 22s ease-in-out -8s infinite alternate; }
@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(6vmax, -4vmax) scale(1.15); }
}
.grade {
  position: absolute; inset: 0;
  background-image: radial-gradient(currentColor 1px, transparent 1px);
  background-size: 26px 26px;
  color: var(--text);
  opacity: .16;
  mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 30%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse 70% 70% at 50% 50%, black 30%, transparent 75%);
}

/* ===== Cartão de vidro ===== */

.palco {
  position: relative; z-index: 1;
  min-height: 100dvh;
  display: grid; place-items: center;
  padding: 24px;
}
.cartao {
  width: min(384px, 100%);
  padding: 34px 30px 30px;
  border-radius: 18px;
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  backdrop-filter: blur(20px) saturate(1.35);
  -webkit-backdrop-filter: blur(20px) saturate(1.35);
  box-shadow: 0 24px 60px -18px rgb(0 0 0 / .55);
  position: relative;
  display: flex; flex-direction: column;
  animation: entrada .55s cubic-bezier(.2, .9, .25, 1.2) both;
}
:root[data-theme="light"] .cartao {
  box-shadow: 0 24px 60px -22px rgb(30 60 120 / .35);
}
/* Anel de gradiente de 1px (truque mask-composite) */
.cartao::before {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(150deg,
    color-mix(in srgb, var(--primaria) 65%, transparent),
    transparent 38%,
    transparent 62%,
    color-mix(in srgb, var(--primaria-3) 55%, transparent));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  mask-composite: exclude;
  pointer-events: none;
}
@keyframes entrada {
  from { opacity: 0; transform: translateY(16px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* ===== Logo e título ===== */

.logo {
  width: 58px; height: 58px;
  align-self: center;
  color: var(--primaria);
  filter: drop-shadow(0 6px 18px color-mix(in srgb, var(--primaria) 55%, transparent));
}
.logo-contorno {
  stroke-dasharray: 70;
  stroke-dashoffset: 70;
  animation: desenhar 1.1s ease-out .15s forwards;
}
@keyframes desenhar { to { stroke-dashoffset: 0; } }

.titulo {
  margin: 14px 0 4px;
  text-align: center;
  font-size: 26px; font-weight: 800; letter-spacing: -.02em;
  background: linear-gradient(90deg, var(--text), var(--primaria) 50%, var(--text));
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  animation: shine 6s linear infinite;
}
@keyframes shine { to { background-position: -200% 0; } }
.subtitulo {
  margin: 0 0 22px;
  text-align: center;
  color: var(--muted);
}

/* ===== Campos ===== */

.campo { margin-bottom: 14px; }
.campo label {
  display: block;
  margin-bottom: 6px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .8px;
  color: var(--muted);
}
.controle { position: relative; }
.controle .icone {
  position: absolute; left: 12px; top: 50%;
  translate: 0 -50%;
  width: 17px; height: 17px;
  color: var(--muted);
  transition: color .18s;
  pointer-events: none;
}
.controle:focus-within .icone { color: var(--primaria); }
.controle input {
  width: 100%;
  padding: 11px 12px 11px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.controle input:focus {
  border-color: var(--primaria);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primaria) 22%, transparent);
}
.olho {
  position: absolute; right: 6px; top: 50%;
  translate: 0 -50%;
  border: 0; background: none;
  padding: 6px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 8px;
  display: grid; place-items: center;
}
.olho:hover { color: var(--text); }
.olho svg { width: 17px; height: 17px; }
.olho .olho-fechado { display: none; }
.olho.mostrando .olho-aberto { display: none; }
.olho.mostrando .olho-fechado { display: block; }

/* ===== Erro (com shake) e avisos ===== */

.erro {
  margin: 2px 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--danger) 45%, transparent);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
  color: var(--danger-text);
  font-size: 13px;
}
.erro.treme { animation: shake .35s; }
@keyframes shake {
  20% { translate: -6px 0; } 40% { translate: 5px 0; }
  60% { translate: -3px 0; } 80% { translate: 2px 0; }
}
.aviso {
  margin: 2px 0 14px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--primaria) 40%, transparent);
  background: color-mix(in srgb, var(--primaria) 10%, transparent);
  font-size: 13px;
}

/* ===== Botão ===== */

.botao {
  position: relative;
  display: flex; align-items: center; justify-content: center; gap: 9px;
  padding: 12px;
  border: 0; border-radius: var(--radius);
  font: inherit; font-weight: 700;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--primaria), var(--primaria-2) 55%, var(--primaria-3));
  background-size: 160% 100%;
  background-position: 0% 0;
  box-shadow: 0 10px 24px -10px color-mix(in srgb, var(--primaria) 70%, transparent);
  transition: background-position .35s, transform .15s, box-shadow .25s;
}
.botao:hover {
  background-position: 100% 0;
  transform: translateY(-1px);
  box-shadow: 0 14px 28px -10px color-mix(in srgb, var(--primaria) 80%, transparent);
}
.botao:active { transform: scale(.99); }
.botao:disabled { opacity: .75; cursor: default; transform: none; }
.botao.secundario {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: none;
  border: 1px solid var(--border);
}
.botao.secundario:hover { border-color: var(--muted); }

.spinner {
  width: 15px; height: 15px;
  border-radius: 50%;
  border: 2px solid rgb(255 255 255 / .35);
  border-top-color: #fff;
  animation: girar .7s linear infinite;
}
@keyframes girar { to { rotate: 360deg; } }

/* ===== Painel ===== */

.pagina-painel { display: flex; flex-direction: column; min-height: 100dvh; }
a.botao { text-decoration: none; text-align: center; }

.topo {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 80%, transparent);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 5;
}
.topo-marca { display: flex; align-items: center; gap: 9px; font-size: 15px; }
.topo-logo { width: 22px; height: 22px; color: var(--primaria); }
.topo-acoes { display: flex; align-items: center; gap: 8px; }
.topo-usuario { color: var(--muted); font-size: 13px; margin-right: 4px; }
.btn-icone {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); border-radius: 8px;
  width: 32px; height: 32px; cursor: pointer; font-size: 15px;
  display: grid; place-items: center;
}
.btn-icone:hover { border-color: var(--muted); }

.abas {
  display: flex; gap: 4px; flex-wrap: wrap;
  padding: 10px 18px 0;
}
.abas button {
  border: 0; background: none; color: var(--muted);
  font: inherit; font-weight: 600;
  padding: 8px 12px; cursor: pointer;
  border-radius: 8px 8px 0 0;
  border-bottom: 2px solid transparent;
}
.abas button:hover { color: var(--text); }
.abas button.ativa { color: var(--primaria); border-bottom-color: var(--primaria); }

.conteudo { padding: 18px; max-width: 1080px; width: 100%; margin: 0 auto; }

.bloco {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}
.bloco h2 { margin: 0 0 12px; font-size: 16px; }
.bloco h2 small { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 8px; }

.linha-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: end; }
.linha-form .campo { margin-bottom: 0; flex: 1 1 150px; }
.campo input, .campo select, .campo textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  outline: none;
}
.campo input:focus, .campo select:focus, .campo textarea:focus {
  border-color: var(--primaria);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primaria) 22%, transparent);
}
.botao.mini { padding: 9px 14px; font-size: 13px; }
.botao.perigo { background: var(--danger); box-shadow: none; }

.tabela-envolta { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; }
tr:last-child td { border-bottom: 0; }
td .acoes { display: flex; gap: 6px; flex-wrap: wrap; }
.acao {
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); border-radius: 7px;
  padding: 4px 9px; font: inherit; font-size: 12px; cursor: pointer;
}
.acao:hover { border-color: var(--muted); }
.acao.perigosa { color: var(--danger-text); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }

.badge {
  display: inline-block; padding: 2px 8px;
  border-radius: 99px; font-size: 11px; font-weight: 700;
}
.badge.ok { background: color-mix(in srgb, var(--success) 18%, transparent); color: var(--success); }
.badge.nao { background: color-mix(in srgb, var(--danger) 15%, transparent); color: var(--danger-text); }
.badge.neutro { background: var(--surface-2); color: var(--muted); }

.qr-caixa {
  background: #fff; border-radius: 12px; padding: 10px;
  width: fit-content; margin: 10px 0;
}
.qr-caixa svg { display: block; width: 210px; height: 210px; }
.segredo-manual {
  font-family: ui-monospace, Consolas, monospace;
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: 8px; padding: 8px 10px;
  letter-spacing: 1px; word-break: break-all;
  user-select: all;
}
.ajuda { color: var(--muted); font-size: 13px; margin: 6px 0; }
.msg-ok { color: var(--success); font-size: 13px; margin-top: 8px; }
.msg-erro { color: var(--danger-text); font-size: 13px; margin-top: 8px; }

.modal-fundo {
  position: fixed; inset: 0; z-index: 20;
  background: rgb(0 0 0 / .55);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 20px;
  width: min(420px, 100%);
}
.modal p { margin: 0 0 14px; }
.modal-botoes { display: flex; gap: 10px; justify-content: flex-end; }
.modal .segredo-manual { margin-bottom: 14px; }

/* ===== Acessibilidade e mobile (§2) ===== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01s !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01s !important;
  }
}
@media (max-width: 480px) {
  .aurora { filter: blur(70px); } /* menos GPU no celular */
  .cartao { padding: 28px 22px 24px; }
}
