/* internal/adminweb/static/style.css — CSS base + biblioteca de componentes
   do painel admin. Vanilla CSS, sem framework, sem build (CLAUDE.md: "Admin
   UI: a-h/templ + HTMX via embed.FS"; stack fixa do projeto).

   Consome só os tokens de internal/adminweb/static/tokens.css (custom
   properties oklch, light + .dark) — nenhuma cor é hardcoded aqui. Ver
   docs/design/admin/TOKENS.md para o mapa nome → valor → uso, e
   docs/design/admin/design.dc.html para a referência visual (mockup .dc,
   NÃO reproduzido literalmente — reescrito em CSS puro + templ + HTMX). */

/* ============================================================ RESET/BASE */

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

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

html.dark {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  line-height: var(--leading-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p {
  margin: 0;
  font-family: var(--font-heading);
}

a {
  color: var(--brand-contrast);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

::selection {
  background: var(--brand-weak);
}

code, .mono {
  font-family: var(--font-mono);
}

/* Foco visível consistente em qualquer elemento interativo (a11y). Só no
   modo teclado (:focus-visible), sem anel em clique de mouse. */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--brand);
  color: var(--brand-fg);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
}

.skip-link:focus-visible {
  left: var(--space-4);
  top: var(--space-4);
}

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

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

/* ============================================================= APP SHELL */

.app-shell {
  display: grid;
  grid-template-columns: 238px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--sidebar);
  color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  padding: var(--space-4) var(--space-3);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: start;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-2) var(--space-4);
}

.sidebar-brand-mark {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: var(--brand-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-lg);
  flex: none;
}

.sidebar-brand-name {
  font-weight: 700;
  font-size: var(--text-sm);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tight);
}

.sidebar-brand-sub {
  font-size: 0.6rem;
  color: var(--sidebar-foreground);
  opacity: 0.6;
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
}

.nav-section-label {
  font-size: 0.65rem;
  color: var(--muted-foreground);
  padding: var(--space-3) var(--space-2) 5px;
  letter-spacing: var(--tracking-wide);
  font-weight: 600;
  text-transform: uppercase;
}

.nav-section-label:first-of-type {
  padding-top: var(--space-2);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  text-align: left;
  font: 500 var(--text-sm) var(--font-sans);
  background: transparent;
  color: var(--sidebar-foreground);
  text-decoration: none;
}

.nav-item svg {
  flex: none;
  opacity: 0.8;
}

.nav-item:hover {
  background: var(--muted);
  text-decoration: none;
}

.nav-item-active,
.nav-item-active:hover {
  background: var(--brand-weak);
  color: var(--brand-contrast);
  font-weight: 600;
}

.nav-item-active svg {
  opacity: 1;
}

.sidebar-user {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.sidebar-user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--muted);
  color: var(--foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 600;
  flex: none;
}

.sidebar-user-name {
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.7rem;
  color: var(--muted-foreground);
}

.content-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-5);
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: var(--background);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-spacer {
  flex: 1;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.content {
  padding: var(--space-6);
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  margin-bottom: 3px;
}

.page-header p {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
}

/* --- Seletor de tenant (topbar) ------------------------------------------
   Placeholder funcional: <form method="get"> sem action reenvia para a URL
   atual preservando o path — funciona em qualquer tela sem o Layout precisar
   saber a rota corrente. Lista real de tenants / nome do tenant atual fica
   para a Fase B (Tasks 8/9), quando os handlers passarem esse dado. */
.tenant-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 38px;
  padding: 0 var(--space-1) 0 var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-xs);
}

.tenant-form-label {
  font-size: 0.6rem;
  color: var(--muted-foreground);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.tenant-form-input {
  width: 4.5rem;
  height: 26px;
  border: none;
  background: transparent;
  color: var(--foreground);
  font: 600 var(--text-sm) var(--font-sans);
  padding: 0;
}

.tenant-form-input:focus-visible {
  /* O anel padrão de :focus-visible fica cortado pelo pill arredondado do
     wrapper; :focus-within no .tenant-form abaixo assume o indicador de
     foco no lugar — sem isso, tabular até este input não mostraria NENHUM
     indicador visível (a11y: foco sempre precisa ser visível). */
  outline: none;
}

.tenant-form:focus-within {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

.tenant-form-submit {
  height: 30px;
  padding: 0 var(--space-2);
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--muted-foreground);
  cursor: pointer;
}

.tenant-form-submit:hover {
  background: var(--muted);
  color: var(--foreground);
}

/* --- Toggle de tema -------------------------------------------------------
   Alterna a classe .dark no <html> — os tokens (Task 1) já têm os dois
   temas. O botão em si é CSS puro (mostra sol/lua via seletor .dark); a
   ÚNICA exceção de JS do admin é o script inline em layout.templ que
   persiste a escolha em localStorage (documentado lá). */
.theme-toggle {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  flex: none;
}

.theme-toggle:hover {
  background: var(--muted);
}

.theme-toggle .icon-sun {
  display: none;
}

html.dark .theme-toggle .icon-moon {
  display: none;
}

html.dark .theme-toggle .icon-sun {
  display: inline-flex;
}

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

.logout-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  cursor: pointer;
  font: 500 var(--text-sm) var(--font-sans);
  color: var(--foreground);
  text-decoration: none;
}

.logout-link:hover {
  background: var(--muted);
  text-decoration: none;
}

/* --- Toggle de sidebar mobile (checkbox hack, CSS puro) ------------------- */

.nav-toggle-input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.nav-toggle-btn {
  display: none;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  cursor: pointer;
  flex: none;
}

.shell-backdrop {
  display: none;
}

/* ================================================================ BOTÕES */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 34px;
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font: 600 var(--text-sm) var(--font-sans);
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.12s ease, filter 0.12s ease;
}

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

.btn-sm {
  height: 30px;
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  border-radius: var(--radius-sm);
}

.btn-primary,
.form-inline button,
button[type="submit"] {
  background: var(--brand);
  color: var(--brand-fg);
  border-color: transparent;
}

.btn-primary:hover,
.form-inline button:hover,
button[type="submit"]:hover {
  background: var(--brand-strong);
}

.btn-secondary {
  background: var(--card);
  color: var(--foreground);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
  font-weight: 500;
}

.btn-secondary:hover {
  background: var(--muted);
}

.btn-ghost {
  background: transparent;
  color: var(--foreground);
  font-weight: 500;
}

.btn-ghost:hover {
  background: var(--muted);
}

.btn-danger,
.btn-danger[type="button"] {
  background: color-mix(in oklch, var(--destructive) 11%, transparent);
  color: var(--destructive-contrast);
  border-color: transparent;
  font-weight: 500;
  height: 30px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  cursor: pointer;
}

.btn-danger:hover {
  background: color-mix(in oklch, var(--destructive) 20%, transparent);
}

/* ================================================================ FORMS */

.form-inline {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: flex-end;
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

input, select, textarea {
  font-family: var(--font-sans);
}

.form-inline input,
.form-inline select,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="search"],
select,
textarea {
  height: 34px;
  padding: 0 var(--space-3);
  background: var(--background);
  color: var(--foreground);
  border: 1px solid var(--input);
  border-radius: var(--radius-md);
  font: 400 var(--text-sm) var(--font-sans);
  box-shadow: var(--shadow-xs);
  outline: none;
}

.form-inline input,
.form-inline select {
  flex: 1 1 160px;
}

input::placeholder, textarea::placeholder {
  color: var(--muted-foreground);
}

input:focus-visible, select:focus-visible, textarea:focus-visible {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
  outline: none;
}

label {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  font-weight: 500;
}

/* ================================================================ TABLE
   Estiliza <table> "crua" (glossary/ignored/cors/apikeys usam markup sem
   classes dedicadas) — cabeçalho, zebra, hover, célula de ações à direita. */

.panel {
  max-width: 100%;
  overflow-x: auto;
}

.panel h1 {
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  margin-bottom: 3px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

th, td {
  text-align: left;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--text-sm);
}

th {
  color: var(--muted-foreground);
  font-weight: 500;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
}

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

tbody tr:nth-child(even) {
  background: color-mix(in oklch, var(--muted) 55%, transparent);
}

tbody tr:hover {
  background: var(--muted);
}

/* Última coluna (célula de ações) alinhada à direita, sem quebra. */
td:last-child {
  text-align: right;
  white-space: nowrap;
}

/* ============================================================== BADGES */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font: 500 var(--text-xs) var(--font-sans);
  background: var(--muted);
  color: var(--muted-foreground);
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex: none;
}

.badge-active {
  background: var(--ok-weak);
  color: var(--ok-contrast);
}

.badge-revoked {
  background: var(--muted);
  /* muted-foreground puro sobre muted mede ~4.34:1 no claro (abaixo de
     4.5:1 AA) — mix com foreground escurece no claro e clareia no escuro,
     melhorando os dois temas com a mesma expressão (sem token dedicado). */
  color: color-mix(in oklch, var(--muted-foreground) 80%, var(--foreground) 20%);
  border: 1px solid var(--border);
}

.badge-degraded {
  background: var(--warn-weak);
  color: var(--warn-contrast);
}

.badge-planned {
  background: var(--brand-weak);
  color: var(--brand-contrast);
}

/* ==================================================== ALERTS (legado)
   Usadas por glossary/ignored/cors/apikeys.templ (Fase B restiliza as
   telas; aqui só re-skinam com os tokens novos). */

.hint {
  color: var(--muted-foreground);
  margin: 0 0 var(--space-4);
  font-size: var(--text-sm);
}

.alert {
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
}

.alert-error {
  background: color-mix(in oklch, var(--destructive) 12%, transparent);
  border: 1px solid var(--destructive);
  color: var(--destructive-contrast);
}

.alert-success {
  background: var(--ok-weak);
  border: 1px solid var(--ok);
  color: var(--ok-contrast);
}

.raw-key {
  display: block;
  margin-top: 6px;
  padding: var(--space-2) var(--space-3);
  background: var(--muted);
  border: 1px dashed var(--ok);
  border-radius: var(--radius-sm);
  word-break: break-all;
  font-family: var(--font-mono);
  color: var(--foreground);
}

.empty {
  color: var(--muted-foreground);
  text-align: center;
}

/* Linha de API key revogada (Task 6): atenuada, mas ainda legível — não some
   da tabela (histórico de auditoria), só perde destaque visual. */
.row-revoked {
  opacity: 0.55;
}

.row-revoked td {
  color: var(--muted-foreground);
}

/* Espaço entre a key revelada e o botão "Copiar" no modal de revelação
   única (Task 6) — sem wrapper extra, só o próximo irmão do .raw-key. */
.raw-key + .btn {
  margin-top: var(--space-3);
}

/* =========================================================== STAT TILE */

.stat-tile {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

.stat-tile-label {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.stat-tile-value {
  font-size: var(--text-3xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  margin-top: var(--space-2);
}

.stat-tile-delta {
  font-size: var(--text-xs);
  margin-top: 3px;
  font-family: var(--font-mono);
  color: var(--muted-foreground);
}

.stat-tile-delta-up {
  color: var(--ok-contrast);
}

.stat-tile-delta-down {
  color: var(--destructive-contrast);
}

/* ========================================================= PROGRESS BAR */

.progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.progress-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--text-sm);
}

.progress-pct {
  font-family: var(--font-mono);
  color: var(--muted-foreground);
  font-size: var(--text-xs);
}

.progress-track {
  height: 10px;
  background: var(--muted);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--brand);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.progress-caption {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

/* ===================================================== BARRA EMPILHADA
   Hit-ratio por nível (L0/L1/L2/L3/API/FALLBACK) — inline divs, sem lib JS. */

/* Wrapper: empilha a barra e a legenda. Sem gap próprio — o espaçamento
   track ↔ legenda vem do margin-top da própria .stacked-bar-legend
   (var(--space-4)), evitando espaço dobrado. */
.stacked-bar {
  display: flex;
  flex-direction: column;
}

.stacked-bar-track {
  display: flex;
  height: 34px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.stacked-bar-seg {
  height: 100%;
}

.stacked-bar-legend {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-5);
}

.stacked-bar-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
}

.stacked-bar-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.stacked-bar-legend-pct {
  color: var(--muted-foreground);
  font-family: var(--font-mono);
}

/* ========================================================== EMPTY STATE */

.empty-state {
  padding: var(--space-12) var(--space-5);
  text-align: center;
}

.empty-state-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--muted);
  color: var(--muted-foreground);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-3);
}

.empty-state-title {
  font-size: var(--text-sm);
  font-weight: 600;
  margin-bottom: 3px;
}

.empty-state-desc {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

/* ===================================================== USO & MÉTRICAS
   Composição da tela de métricas: grade de stat-tiles + cartões (quota,
   barra empilhada). Só tokens — mesmo card (fundo/borda/raio/padding) dos
   demais blocos do painel, extraído de inline-style para casar com os
   outros views (apikeys/cors/glossary/ignored), que só usam classes. */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.metrics-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
}

/* Só cartões intermediários recebem margem inferior; o último (barra
   empilhada) encosta no fim da seção sem folga extra. */
.metrics-card:not(:last-child) {
  margin-bottom: var(--space-5);
}

/* ================================================================= MODAL
   <dialog> nativo, renderizado já aberto pelo servidor quando aplicável
   (ex.: revelação de API key) — "fechar" via <form method="dialog"> nativo,
   sem JS. O pseudo-elemento ::before faz o papel do backdrop (não há
   ::backdrop nativo porque o dialog nasce com o atributo open, não via
   showModal()). */

dialog.modal {
  padding: 0;
  border: none;
  background: transparent;
  max-width: min(500px, calc(100vw - 40px));
  width: 100%;
}

dialog.modal[open] {
  position: fixed;
  inset: 0;
  margin: auto;
  height: fit-content;
  max-height: calc(100vh - 40px);
  z-index: 90;
  animation: modalin 0.18s ease;
}

dialog.modal[open]::before {
  content: "";
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: -1;
}

.modal-card {
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-xl);
  padding: var(--space-6);
  overflow-y: auto;
  max-height: calc(100vh - 40px);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.modal-title {
  font-size: var(--text-lg);
  font-weight: 600;
}

.modal-header form {
  margin: 0;
}

.modal-close {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--muted-foreground);
  flex: none;
}

.modal-close:hover {
  background: var(--muted);
  color: var(--foreground);
}

.modal-body {
  font-size: var(--text-sm);
}

/* ================================================================= TOAST
   Container fixo sempre presente no layout (#toast-region, vazio); handlers
   HTMX anexam @Toast(msg) como hx-swap-oob="true" na resposta do fragmento
   principal — sem endpoint dedicado, sem JS. */

.toast-region {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: var(--space-3) var(--space-4);
  background: var(--foreground);
  color: var(--background);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xl);
  font: 500 var(--text-sm) var(--font-sans);
  animation: toastin 0.22s ease, toastout 0s 4s forwards;
  pointer-events: auto;
}

.toast svg {
  color: var(--ok);
  flex: none;
}

@keyframes toastin {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes toastout {
  to { opacity: 0; visibility: hidden; }
}

@keyframes modalin {
  from { opacity: 0; transform: translateY(12px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

/* ==================================================== LOADING INDICATOR
   Convenção HTMX: .htmx-indicator fica invisível até o HTMX marcar o
   elemento (ou o alvo de hx-indicator) com .htmx-request durante o voo da
   requisição. */

.htmx-indicator {
  opacity: 0;
  transition: opacity 150ms ease-in;
}

.htmx-indicator.htmx-request,
.htmx-request .htmx-indicator {
  opacity: 1;
}

.loading-indicator {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--muted-foreground);
}

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--brand-weak);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* =============================================================== LOGIN
   Tela pré-autenticação (Task 10, Fase B) — views.LoginPage não usa Layout
   (não há sessão para sidebar/tenant/usuário), então não herda .app-shell.
   Card único centralizado, mesmo <body> "solto" (sem grid de shell). */

.login-body {
  min-height: 100vh;
  background: var(--background);
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-6);
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--card);
  color: var(--card-foreground);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-8) var(--space-6);
  text-align: center;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.login-brand-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-lg);
  background: var(--brand);
  color: var(--brand-fg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-xl);
  flex: none;
}

.login-brand-line {
  font-size: var(--text-xs);
  color: var(--muted-foreground);
  font-weight: 600;
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.login-title {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: var(--tracking-tight);
  margin-bottom: var(--space-2);
}

.login-desc {
  color: var(--muted-foreground);
  font-size: var(--text-sm);
  margin-bottom: var(--space-6);
}

.login-cta {
  width: 100%;
  height: 40px;
}

@media (max-width: 420px) {
  .login-page {
    padding: var(--space-4);
  }

  .login-card {
    padding: var(--space-6) var(--space-5);
  }
}

/* =========================================================== RESPONSIVE
   Sidebar colapsa em telas estreitas via checkbox hack — sem JS. */

@media (max-width: 880px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .nav-toggle-btn {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 258px;
    min-height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 40;
    box-shadow: var(--shadow-xl);
  }

  .nav-toggle-input:checked ~ .app-shell .sidebar {
    transform: translateX(0);
  }

  .nav-toggle-input:checked ~ .app-shell .shell-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--overlay);
    z-index: 39;
  }

  .content {
    padding: var(--space-4);
  }

  .user-email {
    display: none;
  }
}

@media (max-width: 560px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .form-inline input,
  .form-inline select {
    flex-basis: 100%;
  }
}
