/* =====================================================================
   Sistemas Perseverança — estilos (mobile-first, sem dependências externas)
   Sem fontes/scripts de terceiros: compatível com CSP "default-src 'none'".
   ===================================================================== */

:root {
  --brand-1: #3b3fd8;
  --brand-2: #7a3fe0;
  --brand-3: #22b3c4;
  --bg: #f4f5fb;
  --surface: #ffffff;
  --surface-2: #f0f1f9;
  --text: #171b30;
  --text-soft: #565d78;
  --text-faint: #8087a2;
  --border: #dcdfee;
  --ring: rgba(59, 63, 216, 0.35);
  --primary: #3b3fd8;
  --primary-hover: #2f33bd;
  --primary-contrast: #ffffff;
  --danger: #c0264a;
  --danger-bg: #fdecf0;
  --success: #12805c;
  --success-bg: #e6f6ef;
  --warn: #9a5b00;
  --warn-bg: #fff4de;
  --info: #2a4fd0;
  --info-bg: #e9efff;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 27, 48, 0.06), 0 12px 32px rgba(23, 27, 48, 0.1);
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1120;
    --surface: #171b30;
    --surface-2: #1e2340;
    --text: #eef0fb;
    --text-soft: #b0b6d2;
    --text-faint: #7d84a6;
    --border: #2b3154;
    --ring: rgba(138, 141, 255, 0.45);
    --primary: #6d71ff;
    --primary-hover: #8285ff;
    --primary-contrast: #0e1120;
    --danger: #ff7a97;
    --danger-bg: #3a1a26;
    --success: #4fd6a2;
    --success-bg: #12302a;
    --warn: #ffc064;
    --warn-bg: #362a12;
    --info: #9db5ff;
    --info-bg: #1b2447;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  display: block;
  max-width: 100%;
}

a {
  color: var(--primary);
  text-underline-offset: 3px;
}
a:hover {
  color: var(--primary-hover);
}

:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 6px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* ---------------------------------------------------------- Layout de autenticação */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

.auth-brand {
  position: relative;
  overflow: hidden;
  color: #fff;
  padding: max(1.25rem, env(safe-area-inset-top)) max(1.25rem, env(safe-area-inset-right)) 1.5rem
    max(1.25rem, env(safe-area-inset-left));
  background: linear-gradient(135deg, var(--brand-1) 0%, var(--brand-2) 60%, #5b2fc4 100%);
}

.auth-brand::before,
.auth-brand::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
}
.auth-brand::before {
  width: 320px;
  height: 320px;
  right: -110px;
  top: -140px;
  background: radial-gradient(circle, rgba(34, 179, 196, 0.55), transparent 65%);
}
.auth-brand::after {
  width: 260px;
  height: 260px;
  left: -90px;
  bottom: -130px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.18), transparent 65%);
}

.brand-row {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.brand-row img {
  width: 44px;
  height: 44px;
  flex: none;
}
.brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.15;
}
.brand-name small {
  display: block;
  font-weight: 500;
  font-size: 0.78rem;
  opacity: 0.85;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.brand-copy {
  display: none;
  position: relative;
  z-index: 1;
}

.auth-panel {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 1.25rem max(1rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom))
    max(1rem, env(safe-area-inset-left));
}

.card {
  width: 100%;
  max-width: 440px;
  margin-top: -2.25rem; /* sobrepõe levemente a faixa da marca no mobile */
  position: relative;
  z-index: 2;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.25rem, 5vw, 2rem);
}

.card h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.4rem, 5vw, 1.75rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.card .lead {
  margin: 0 0 1.5rem;
  color: var(--text-soft);
  font-size: 0.975rem;
}

@media (min-width: 960px) {
  .auth-shell {
    grid-template-columns: minmax(340px, 5fr) minmax(420px, 6fr);
    grid-template-rows: 1fr;
  }
  .auth-brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem clamp(2rem, 5vw, 4.5rem);
    min-height: 100vh;
    min-height: 100dvh;
  }
  .brand-row img {
    width: 52px;
    height: 52px;
  }
  .brand-name {
    font-size: 1.3rem;
  }
  .brand-copy {
    display: block;
    max-width: 30rem;
  }
  .brand-copy h2 {
    margin: 0 0 0.75rem;
    font-size: clamp(1.8rem, 2.6vw, 2.5rem);
    line-height: 1.15;
    letter-spacing: -0.02em;
  }
  .brand-copy p {
    margin: 0;
    font-size: 1.05rem;
    opacity: 0.9;
  }
  .brand-foot {
    position: relative;
    z-index: 1;
    display: block;
    font-size: 0.85rem;
    opacity: 0.8;
  }
  .auth-panel {
    align-items: center;
    padding: 2rem;
  }
  .card {
    margin-top: 0;
  }
}
.brand-foot {
  display: none;
}

/* --------------------------------------------------------------- Formulário */
.form {
  display: grid;
  gap: 1.1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}
.field > label,
.label-row > label {
  font-weight: 600;
  font-size: 0.9rem;
}
.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}
.label-row a {
  font-size: 0.875rem;
  font-weight: 500;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.input-wrap > .icon {
  position: absolute;
  left: 0.9rem;
  width: 1.15rem;
  height: 1.15rem;
  color: var(--text-faint);
  pointer-events: none;
}

.input {
  width: 100%;
  min-height: 48px; /* alvo de toque confortável */
  padding: 0.7rem 0.95rem 0.7rem 2.7rem;
  font: inherit;
  font-size: 1rem; /* 16px: evita zoom automático no iOS */
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.input::placeholder {
  color: var(--text-faint);
}
.input:hover {
  border-color: var(--text-faint);
}
.input:focus {
  outline: none;
  background: var(--surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}
.input[aria-invalid='true'] {
  border-color: var(--danger);
}
.input.has-toggle {
  padding-right: 3.1rem;
}

.toggle-pass {
  position: absolute;
  right: 0.25rem;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  color: var(--text-soft);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.toggle-pass:hover {
  color: var(--text);
  background: var(--surface);
}
.toggle-pass svg {
  width: 1.25rem;
  height: 1.25rem;
}

.field-error {
  margin: 0;
  min-height: 0;
  font-size: 0.85rem;
  color: var(--danger);
}
.field-error:empty {
  display: none;
}

/* Honeypot: fora da tela, invisível para pessoas e leitores de tela */
.hp {
  position: absolute !important;
  left: -10000px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* ------------------------------------------------------------------- Botões */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-weight: 650;
  font-size: 1rem;
  text-decoration: none;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, border-color 0.15s, opacity 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active {
  transform: translateY(1px);
}
.btn-primary {
  color: var(--primary-contrast);
  background: linear-gradient(135deg, var(--primary), var(--brand-2));
  background-color: var(--primary);
}
.btn-primary:hover {
  color: var(--primary-contrast);
  filter: brightness(1.08);
}
.btn-outline {
  color: var(--text);
  background: transparent;
  border-color: var(--border);
}
.btn-outline:hover {
  color: var(--text);
  border-color: var(--primary);
  background: var(--surface-2);
}
.btn-sm {
  min-height: 40px;
  padding: 0.4rem 0.9rem;
  font-size: 0.9rem;
}
.btn-danger {
  color: var(--danger);
  background: transparent;
  border-color: var(--danger);
}
.btn-danger:hover {
  color: var(--danger);
  background: var(--danger-bg);
}
.btn-block {
  width: 100%;
}
.btn[disabled],
.btn[aria-busy='true'] {
  opacity: 0.65;
  cursor: not-allowed;
}
.btn[aria-busy='true']::before {
  content: '';
  width: 1em;
  height: 1em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: giro 0.7s linear infinite;
}
@keyframes giro {
  to {
    transform: rotate(360deg);
  }
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.25rem 0;
  color: var(--text-faint);
  font-size: 0.85rem;
}
.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.foot-links {
  margin: 1.25rem 0 0;
  text-align: center;
  font-size: 0.925rem;
  color: var(--text-soft);
}

/* ------------------------------------------------------------------ Alertas */
.alert {
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
  padding: 0.8rem 0.95rem;
  margin: 0 0 1.1rem;
  font-size: 0.925rem;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}
.alert svg {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.12rem;
}
.alert-error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: color-mix(in srgb, var(--danger) 30%, transparent);
}
.alert-success {
  color: var(--success);
  background: var(--success-bg);
  border-color: color-mix(in srgb, var(--success) 30%, transparent);
}
.alert-info {
  color: var(--info);
  background: var(--info-bg);
  border-color: color-mix(in srgb, var(--info) 30%, transparent);
}
.alert-warn {
  color: var(--warn);
  background: var(--warn-bg);
  border-color: color-mix(in srgb, var(--warn) 30%, transparent);
}

/* ------------------------------------------------ Força e regras da senha */
.strength {
  display: grid;
  gap: 0.5rem;
}
.strength-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}
.strength-bar span {
  height: 5px;
  border-radius: 99px;
  background: var(--border);
  transition: background 0.2s;
}
.strength[data-nivel='1'] .strength-bar span:nth-child(-n + 1) {
  background: var(--danger);
}
.strength[data-nivel='2'] .strength-bar span:nth-child(-n + 2) {
  background: var(--warn);
}
.strength[data-nivel='3'] .strength-bar span:nth-child(-n + 3) {
  background: var(--info);
}
.strength[data-nivel='4'] .strength-bar span {
  background: var(--success);
}
.strength-label {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-soft);
}
.rules {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.2rem 0.75rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8rem;
  color: var(--text-faint);
}
.rules li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.rules li::before {
  content: '';
  flex: none;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  border: 1.5px solid currentColor;
}
.rules li.ok {
  color: var(--success);
}
.rules li.ok::before {
  background: currentColor;
  box-shadow: inset 0 0 0 2px var(--surface);
}

/* ------------------------------------------------------- Estado de resultado */
.result {
  text-align: center;
  padding: 0.5rem 0;
}
.result .badge {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  color: var(--success);
  background: var(--success-bg);
}
.result .badge.bad {
  color: var(--danger);
  background: var(--danger-bg);
}
.result .badge svg {
  width: 32px;
  height: 32px;
}
.result h1 {
  margin-bottom: 0.5rem;
}
.result p {
  margin: 0 0 1.5rem;
  color: var(--text-soft);
}

/* ------------------------------------------------------ Área logada (painel) */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem max(1rem, env(safe-area-inset-right)) 0.65rem max(1rem, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .brand-mini {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  min-width: 0;
}
.topbar .brand-mini img {
  width: 34px;
  height: 34px;
  flex: none;
}
.topbar .brand-mini span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar nav {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 2rem) max(1rem, env(safe-area-inset-right))
    max(2rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
}
.page h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  line-height: 1.2;
}
.page .lead {
  margin: 0 0 1.5rem;
  color: var(--text-soft);
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1rem, 3vw, 1.5rem);
}

.tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1rem;
}
.tab {
  min-height: 40px;
  padding: 0.4rem 0.95rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 99px;
  cursor: pointer;
}
.tab[aria-selected='true'] {
  color: var(--primary-contrast);
  background: var(--primary);
  border-color: var(--primary);
}

/* Tabela que vira "cartões" no celular */
.tbl {
  width: 100%;
  border-collapse: collapse;
}
.tbl th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.tbl td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  word-break: break-word;
}
.tbl tr:last-child td {
  border-bottom: 0;
}
.tbl .acoes {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.pill {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  font-size: 0.78rem;
  font-weight: 650;
  border-radius: 99px;
}
.pill-pendente {
  color: var(--warn);
  background: var(--warn-bg);
}
.pill-aprovado {
  color: var(--success);
  background: var(--success-bg);
}
.pill-bloqueado {
  color: var(--danger);
  background: var(--danger-bg);
}
.pill-neutro {
  color: var(--text-soft);
  background: var(--surface-2);
}

@media (max-width: 720px) {
  .tbl,
  .tbl tbody,
  .tbl tr,
  .tbl td {
    display: block;
    width: 100%;
  }
  .tbl thead {
    position: absolute;
    left: -10000px;
  }
  .tbl tr {
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
  }
  .tbl td {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.35rem 0;
    border: 0;
    text-align: right;
  }
  .tbl td::before {
    content: attr(data-rotulo);
    flex: none;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
  }
  .tbl td.acoes-td {
    display: block;
    text-align: left;
  }
  .tbl td.acoes-td::before {
    display: none;
  }
}

.vazio {
  margin: 0;
  padding: 2rem 0.5rem;
  text-align: center;
  color: var(--text-soft);
}

.skeleton {
  height: 1rem;
  width: 60%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2));
  background-size: 200% 100%;
  animation: brilho 1.2s ease-in-out infinite;
}
@keyframes brilho {
  to {
    background-position: -200% 0;
  }
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
  gap: 1rem;
}
.tile {
  display: grid;
  gap: 0.35rem;
  padding: 1.1rem;
  color: var(--text);
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tile:hover {
  color: var(--text);
  border-color: var(--primary);
}
.tile strong {
  font-size: 1.05rem;
}
.tile span {
  font-size: 0.9rem;
  color: var(--text-soft);
}

/* ------------------------------------------- Botão com aparência de link */
.link-btn {
  padding: 0;
  font: inherit;
  font-weight: 500;
  color: var(--primary);
  background: none;
  border: 0;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.link-btn:hover {
  color: var(--primary-hover);
}
.link-btn:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------ Cabeçalho de página */
.page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem 1rem;
}
.page-head > div {
  flex: 1 1 260px;
  min-width: 0;
}
.page-head > .btn {
  flex: none;
}

/* Campo de texto sem ícone à esquerda */
.input.input-plain {
  padding-left: 0.95rem;
}

/* ----------------------------------------------------------- Diálogos */
dialog {
  width: min(92vw, 440px);
  max-height: 90dvh;
  margin: auto;
  padding: clamp(1.1rem, 4vw, 1.6rem);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: auto;
}
dialog::backdrop {
  background: rgba(10, 12, 28, 0.55);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
}
dialog h2 {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
}
dialog .lead {
  margin: 0 0 1rem;
  color: var(--text-soft);
}
.dlg-acoes {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}
@media (max-width: 460px) {
  .dlg-acoes .btn {
    flex: 1 1 100%;
  }
}

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

@media (max-width: 460px) {
  .topbar .brand-mini span {
    display: none; /* em telas muito estreitas sobra espaço para os botões */
  }
}
