/* ============================================================
   Apurei — style-views.css
   Telas e zonas específicas

   Responsabilidades deste arquivo:
     - Tela de login (magic link)
     - Animações de entrada das zonas
     - Zona A: formulário de nova apuração
     - Zona B: indicador de progresso
     - Zona C: resultado (cabeçalho, cards, tabela, controles de linha)
     - Layer 2: análise detalhada (gráfico, composição, estabilidade)
     - Tela de bloqueio/erro
     - Flags e badges de classificação
     - Totais mensais

   Edite este arquivo para:
     - Mudar o layout ou aparência de uma tela específica
     - Ajustar cards, tabela ou controles do resultado
     - Modificar cores de flags e badges
   ============================================================ */

/* ============================================================
   TELA DE LOGIN (magic link)
   ============================================================ */

.apurei-login-wrap {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
}

.apurei-login-brand {
  text-align: center;
  margin-bottom: 40px;
}

.apurei-login-logo {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 500;
  color: var(--c-ink);
  letter-spacing: -0.02em;
  display: block;
}

.apurei-login-tagline {
  margin-top: 6px;
  font-size: 14px;
  color: var(--c-muted);
}

.apurei-login-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 36px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
}

.apurei-login-instruction {
  font-size: 14px;
  color: var(--c-muted);
  margin-bottom: 20px;
  line-height: 1.6;
}

.apurei-login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.apurei-login-feedback {
  margin-top: 14px;
  font-size: 13px;
  min-height: 20px;
}

.apurei-login-feedback.success { color: var(--c-ok); }
.apurei-login-feedback.error   { color: var(--c-error); }

/* ── Animação de entrada para as zonas ───────────────────── */
@keyframes apurei-fade-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   ZONA A — FORMULÁRIO chat-style
   ============================================================ */

.apurei-zone-form {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 32px;
  gap: 28px;
  animation: apurei-fade-in 0.25s ease both;
}

/* ── Saudação ──────────────────────────────────────────────── */

.apurei-greeting {
  text-align: center;
  max-width: 580px;
}

.apurei-greeting-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  color: var(--c-ink);
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin-bottom: 10px;
}

.apurei-greeting-sub {
  font-size: 14px;
  color: var(--c-muted);
  line-height: 1.6;
}

/* ── Caixa de entrada (chat box) ──────────────────────────── */

.apurei-chat-box {
  width: 100%;
  max-width: 620px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  /* overflow: hidden removido para o balão de hint escapar pelo topo */
}

/* Inputs internos: titular + familiares */
.apurei-chat-fields {
  display: flex;
  flex-direction: column;
}

.apurei-chat-field-input {
  width: 100%;
  padding: 15px 18px;
  font-size: 14px;
  font-family: inherit;
  color: var(--c-ink);
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--c-border);
  outline: none;
  transition: background 0.15s;
  -webkit-appearance: none;
}

.apurei-chat-field-input:focus,
.apurei-chat-field-input:focus-visible {
  background: #f8f8f6;
  border-bottom-color: #999;
  outline: none !important;
  box-shadow: none !important;
}

.apurei-chat-field-input::placeholder {
  color: var(--c-muted);
}

/* Dropzone fantasma: sem visual, somente wrapper do input para o JS */
.apurei-dropzone-ghost {
  display: none !important;
}

/* Pós-seleção dentro do chat box */
.apurei-chat-box .apurei-post-upload {
  margin: 0;
  border-bottom: 1px solid var(--c-border);
}

.apurei-chat-box .apurei-file-info {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 9px 18px;
  font-size: 13px;
}

/* Separador horizontal */
.apurei-chat-sep {
  height: 1px;
  background: var(--c-border);
}

/* Rodapé da caixa: toolbox + filtros + send */
.apurei-chat-bottom {
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.apurei-chat-bottom .apurei-toolbox {
  padding: 0;
}

.apurei-chat-bottom .apurei-submit-row {
  padding: 0;
}

/* ── Botão enviar (corrige invisibilidade causada pelo reset de button) ── */

.apurei-root .apurei-send-btn {
  background: var(--c-ink) !important;
  border: none !important;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  color: #fff;
}

.apurei-root .apurei-send-btn:hover  { opacity: 0.82; }
.apurei-root .apurei-send-btn:active { transform: scale(0.93); }

.apurei-root .apurei-send-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Chip "+ PDFs" — sempre ativo ────────────────────────────────────────── */

.apurei-tool-chip--upload {
  cursor: pointer;
  position: relative;          /* ancora o balão de hint */
  border-color: var(--c-ink);  /* contorno sólido = sempre ativo */
  color: var(--c-ink);
  font-weight: 500;
}

.apurei-tool-chip--upload:hover {
  background: #f0ede8;
}

/* ── Balão de dica "Suba seus PDFs aqui" ─────────────────────────────────── */

.apurei-upload-hint {
  position: absolute;
  bottom: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-ink);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 11px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;
  /* Aparece imediatamente, some após 6 s com fade de 0,5 s */
  animation: apurei-hint-fade 0.5s ease 6s forwards;
}

/* Triângulo inferior do balão */
.apurei-upload-hint::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--c-ink);
}

@keyframes apurei-hint-fade {
  to { opacity: 0; }
}

/* Compatibilidade: manter form-card caso ainda exista em algum estado */
.apurei-form-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 32px 32px 28px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
}

/* ============================================================
   ZONA B — PROGRESSO
   ============================================================ */

.apurei-zone-progress {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  animation: apurei-fade-in 0.25s ease both;
}

.apurei-progress-wrap {
  max-width: 400px;
  width: 100%;
  text-align: left;
}

.apurei-progress-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 28px;
  color: var(--c-ink);
}

.apurei-progress-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.apurei-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  color: var(--c-muted);
  transition: color 0.3s;
}

.apurei-step::before {
  content: '';
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--c-step-pend);
  flex-shrink: 0;
  transition: all 0.3s;
}

.apurei-step.done { color: var(--c-ink); }

.apurei-step.done::before {
  border-color: var(--c-step-done);
  background: var(--c-step-done);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='8' viewBox='0 0 10 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4l3 3 5-6' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.apurei-step.active { color: var(--c-ink); }

.apurei-step.active::before {
  border-color: var(--c-ink);
  animation: apurei-pulse 1s ease infinite;
}

@keyframes apurei-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

/* ── Stream de lançamentos (decorativo durante processamento) ── */

.apurei-stream {
  position: relative;
  height: 112px;
  overflow: hidden;
  margin-top: 28px;
  border-radius: var(--radius);
  opacity: 0;
  transition: opacity 0.7s ease;
  pointer-events: none;
}

.apurei-stream.running {
  opacity: 1;
}

/* Fade-out nas bordas superior e inferior */
.apurei-stream::before,
.apurei-stream::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  height: 40px;
  z-index: 2;
  pointer-events: none;
}

.apurei-stream::before {
  top: 0;
  background: linear-gradient(to bottom, var(--c-bg, #f5f5f3), transparent);
}

.apurei-stream::after {
  bottom: 0;
  background: linear-gradient(to top, var(--c-bg, #f5f5f3), transparent);
}

/* Cada linha flutuante */
.apurei-stream-row {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 12px;
  background: var(--c-surface, #fff);
  border: 1px solid var(--c-border);
  border-radius: 6px;
  animation: apurei-rise var(--rise-dur, 2.8s) ease-out forwards;
}

@keyframes apurei-rise {
  0%   { transform: translateY(4px);    opacity: 0;    }
  14%  { opacity: 0.9; }
  72%  { opacity: 0.75; }
  100% { transform: translateY(-158px); opacity: 0;    }
}

.apurei-stream-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.apurei-stream-dot.e { background: var(--c-step-done, #1a6b3c); }
.apurei-stream-dot.s { background: #d94f4f; }

.apurei-stream-bar {
  height: 9px;
  border-radius: 4px;
  background: var(--c-border);
  flex: 1;
}

.apurei-stream-val {
  width: 52px;
  height: 9px;
  border-radius: 4px;
  flex-shrink: 0;
}

.apurei-stream-val.e {
  background: color-mix(in srgb, var(--c-step-done, #1a6b3c) 30%, transparent);
}

.apurei-stream-val.s {
  background: color-mix(in srgb, #d94f4f 22%, transparent);
}

/* Modo com dados reais: texto de descrição e valor monetário */
.apurei-stream-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .02em;
  color: var(--c-text-muted, #888);
  opacity: .85;
}

.apurei-stream-amount {
  flex-shrink: 0;
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  letter-spacing: .01em;
}

.apurei-stream-amount.e {
  color: var(--c-step-done, #1a6b3c);
}

.apurei-stream-amount.s {
  color: #d94f4f;
}

/* ============================================================
   ZONA C — RESULTADO
   ============================================================ */

.apurei-zone-result {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: apurei-fade-in 0.25s ease both;
}

/* Cabeçalho fixo do resultado */
.apurei-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px 12px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}

.apurei-result-header-info {
  min-width: 0;
  flex: 1;
}

.apurei-result-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--c-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apurei-result-meta {
  font-size: 11px;
  color: var(--c-muted);
  margin-top: 2px;
}

/* Lado direito do cabeçalho: banner + botão de laudo */
.apurei-result-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Banner de recálculo (forcar_estavel) */
.apurei-recalc-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: #fffbeb;
  border: 1px solid #fcd34d;
  color: #78350f;
  font-size: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

.apurei-recalc-banner button {
  background: #78350f;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
}

.apurei-recalc-banner button:hover { opacity: 0.85; }

/* Botão Exportar laudo */
.apurei-export-laudo-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 13px;
  font-size: 12px;
  font-family: inherit;
  font-weight: 500;
  color: var(--c-ink);
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.apurei-export-laudo-btn:hover {
  border-color: var(--c-ink);
  background: #f5f5f3;
}

/* Corpo scrollável do resultado */
.apurei-result-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── Cards de resumo (faixa horizontal com separadores verticais) ── */
.apurei-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 24px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.apurei-card {
  padding: 20px 24px;
  border-right: 1px solid var(--c-border);
}

.apurei-card:last-child {
  border-right: none;
}

.apurei-card-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin-bottom: 8px;
}

.apurei-card-value {
  font-family: var(--font-serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--c-ink);
  letter-spacing: -0.02em;
  line-height: 1;
}

/* Valor menor: usado no card de estabilidade (texto curto mas variável) */
.apurei-card-value--sm {
  font-size: 20px;
  line-height: 1.2;
}

.apurei-card-sub {
  font-size: 12px;
  color: var(--c-muted);
  margin-top: 6px;
}

.apurei-card-main {
  background: #fafaf8;
}

.apurei-card-main .apurei-card-value {
  font-size: 28px;
}

/* Badge de variação da estabilidade */
.apurei-estab-variacao {
  display: inline-block;
  margin-top: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 99px;
}

.apurei-estab-variacao--alta  { background: #eaf4ee; color: #1a6b3c; }
.apurei-estab-variacao--media { background: #f2f2f0; color: #555555; }
.apurei-estab-variacao--baixa { background: #fef3dc; color: #7a4f00; }

/* Valor do card de estabilidade: herda cor do badge irmão via container */
#card-estabilidade { transition: color 0.2s; }

/* Quando o badge--baixa está presente, o valor do card fica âmbar */
.apurei-card:has(.apurei-estab-variacao--baixa) #card-estabilidade { color: #7a4f00; }
.apurei-card:has(.apurei-estab-variacao--alta)  #card-estabilidade { color: #1a6b3c; }

/* ── Tabela ───────────────────────────────────────────────── */
.apurei-table-wrap {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.apurei-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--c-border);
  background: #fafaf8;
  flex-shrink: 0;
}

.apurei-table-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-muted);
}

/* Tag de filtro ativo */
.apurei-filter-tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--c-ink);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px 3px 10px;
  border-radius: 99px;
}

.apurei-filter-tag-clear {
  background: none;
  border: none;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 0 2px;
  opacity: 0.7;
  font-family: inherit;
}

.apurei-filter-tag-clear:hover { opacity: 1; }

.apurei-table-scroll {
  overflow-y: auto;
  max-height: calc(100vh - 400px);
  min-height: 120px;
}

.apurei-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  table-layout: fixed;   /* previne que colunas longas empurrem Ações */
}

/* Larguras fixas das colunas */
.apurei-table th:nth-child(1) { width: 88px;  }   /* Data */
.apurei-table th:nth-child(2) { width: auto;  }   /* Origem (expansível) */
.apurei-table th:nth-child(3) { width: 100px; }   /* Valor */
.apurei-table th:nth-child(4) { width: 118px; }   /* Classificação */
.apurei-table th:nth-child(5) { width: 230px; }   /* Ações */

/* Célula de origem: trunca com ellipsis */
.apurei-table td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 0;           /* necessário com table-layout: fixed para ellipsis funcionar */
}

.apurei-table th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-muted);
  border-bottom: 1px solid var(--c-border);
  background: #fafaf8;
  position: sticky;
  top: 0;
  z-index: 1;
}

.apurei-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--c-border);
  vertical-align: middle;
}

.apurei-table tr:last-child td { border-bottom: none; }
.apurei-table tr:hover td      { background: #fafaf8; }
.apurei-table .mono            { font-family: var(--font-mono); font-size: 12px; }
.apurei-col-data               { color: var(--c-muted); }

.apurei-table tr.overridden td { background: #fefdf5; }

/* Excluído pelo usuário: linha riscada e esmaecida */
.apurei-table tr.excluded td {
  opacity: 0.38;
  text-decoration: line-through;
  text-decoration-color: var(--c-muted);
}

/* Excluído pelo sistema (backend): texto muted, sem risco — deixa claro
   que é uma decisão do sistema, não do usuário */
.apurei-table tr.system-excluded td {
  color: var(--c-muted);
  background: #fafaf8;
}
.apurei-table tr.system-excluded .apurei-classif {
  opacity: 0.65;
}

/* Override controls — coluna Ações */
.apurei-override {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.apurei-toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.apurei-toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.apurei-toggle-track {
  position: absolute;
  inset: 0;
  background: var(--c-border);
  border-radius: 20px;
  cursor: pointer;
  transition: background 0.2s;
}

.apurei-toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
}

.apurei-toggle input:checked + .apurei-toggle-track {
  background: var(--c-ok);
}

.apurei-toggle input:checked + .apurei-toggle-track::after {
  transform: translateX(16px);
}

/* Ícone de nota (balão) — visível apenas no hover da linha */
.apurei-nota-icon {
  background: none;
  border: none;
  padding: 2px 3px;
  cursor: pointer;
  color: var(--c-muted);
  border-radius: 3px;
  display: inline-flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  flex-shrink: 0;
}

.apurei-table tr:hover .apurei-nota-icon { opacity: 1; }
.apurei-nota-icon:hover                  { color: var(--c-ink); }

/* Permanece visível quando já há nota */
.apurei-nota-icon--has-nota {
  opacity: 1 !important;
  color: var(--c-ink);
}

/* Campo de nota inline */
.apurei-nota-field {
  font-size: 12px;
  color: var(--c-ink);
  border: none;
  border-bottom: 1px solid var(--c-border);
  background: transparent;
  outline: none;
  width: 140px;
  padding: 2px 0;
  flex-shrink: 0;
}

.apurei-nota-field:focus { border-color: var(--c-ink); }

.apurei-override-icon { font-size: 11px; color: var(--c-warn); }

/* Expandir camada 2 */
.apurei-expand-btn {
  display: block;
  text-align: center;
  width: 100%;
  padding: 14px;
  font-size: 13px;
  color: var(--c-muted);
  background: none;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s;
  margin-bottom: 16px;
}

.apurei-expand-btn:hover {
  color: var(--c-ink);
  border-color: var(--c-ink);
}

/* Footer do resultado */
.apurei-result-footer {
  padding: 8px 0 4px;
}

/* ============================================================
   LAYER 2 — Análise detalhada
   ============================================================ */

.apurei-layer2 {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.apurei-layer2-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.apurei-layer2-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
  margin-bottom: 16px;
}

.apurei-layer2-empty {
  font-size: 13px;
  color: var(--c-muted);
}

/* Composição por origem */
.apurei-composition {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.apurei-comp-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.apurei-comp-header {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
}

.apurei-comp-name { font-weight: 500; }

.apurei-comp-bar-wrap {
  height: 6px;
  background: var(--c-border);
  border-radius: 3px;
  overflow: hidden;
}

.apurei-comp-bar {
  height: 100%;
  background: var(--c-ink);
  border-radius: 3px;
  transition: width 0.6s ease;
}

/* Baixa confiança */
.apurei-low-confidence {
  background: var(--c-warn-bg);
  color: var(--c-warn);
  border: 1px solid rgba(122,79,0,.15);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 24px;
  line-height: 1.5;
}

/* ============================================================
   TELA DE BLOQUEIO
   ============================================================ */

.apurei-root-blocked {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.apurei-blocked-wrap {
  max-width: 400px;
  width: 100%;
  text-align: center;
  padding: 48px 24px;
}

.apurei-blocked-icon {
  color: var(--c-muted);
  margin-bottom: 24px;
}

.apurei-blocked-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  margin-bottom: 12px;
}

.apurei-blocked-msg {
  font-size: 15px;
  color: var(--c-ink);
  margin-bottom: 8px;
}

.apurei-blocked-sub {
  font-size: 14px;
  color: var(--c-muted);
  margin-bottom: 32px;
  line-height: 1.5;
}

.apurei-blocked-support {
  margin-top: 24px;
  font-size: 13px;
  color: var(--c-muted);
}

.apurei-blocked-support a { color: var(--c-ink); }

/* ============================================================
   FLAGS E BADGES DE CLASSIFICAÇÃO
   ============================================================ */

/* Flags */
.apurei-flag {
  display: inline-block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 2px;
  margin-left: 6px;
  vertical-align: middle;
  white-space: nowrap;
}

.apurei-flag--salario        { background: #eaf4ee; color: #1a6b3c; }
.apurei-flag--bonus          { background: #fef3dc; color: #7a4f00; }
.apurei-flag--pontual        { background: #f0f0f0; color: #555555; }
.apurei-flag--ignorar        { background: #fdecea; color: #7a1a1a; }
.apurei-flag--forcar_estavel { background: #e8edf8; color: #1a3a7a; }

/* Select de flag */
.apurei-flag-select {
  font-size: 11px;
  font-family: inherit;
  color: var(--c-muted);
  background: transparent;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 3px 6px;
  cursor: pointer;
  outline: none;
  max-width: 110px;
  width: 110px;
  flex-shrink: 0;
  transition: border-color 0.15s;
}

.apurei-flag-select:hover,
.apurei-flag-select:focus { border-color: var(--c-ink); color: var(--c-ink); }

/* Classificação: dois estados principais + legado */
.apurei-classif--estavel  { background: #eaf4ee; color: #1a6b3c; }
.apurei-classif--eventual { background: #fef3dc; color: #7a4f00; }
.apurei-classif--forcado  { background: #e8edf8; color: #1a3a7a; }
.apurei-classif--flag     { background: var(--c-error-bg); color: var(--c-error); }

/* ============================================================
   TOTAL POR MÊS
   ============================================================ */

.apurei-totais-mes {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.apurei-totais-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
}

.apurei-totais-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.apurei-totais-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.apurei-totais-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #fafaf8;
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  padding: 9px 14px;
  min-width: 76px;
  gap: 3px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.apurei-totais-item:hover {
  border-color: var(--c-ink);
  background: #f0ede8;
}

/* Estado ativo: inversão de cor */
.apurei-totais-item.active {
  background: var(--c-ink);
  border-color: var(--c-ink);
}

.apurei-totais-item.active .apurei-totais-mes-label,
.apurei-totais-item.active .apurei-totais-valor {
  color: #fff;
}

/* Botão Editar adapta ao fundo escuro quando o card está ativo */
.apurei-totais-item.active .apurei-edit-mes-btn {
  border-color: rgba(255,255,255,0.3);
  color: rgba(255,255,255,0.75);
  background: transparent;
}
.apurei-totais-item.active .apurei-edit-mes-btn:hover {
  border-color: rgba(255,255,255,0.7);
  color: #fff;
  background: rgba(255,255,255,0.12);
}

/* Meses sem renda: opacidade reduzida */
.apurei-totais-item--zero {
  opacity: 0.45;
}

.apurei-totais-mes-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--c-muted);
  transition: color 0.15s;
}

.apurei-totais-valor {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--c-ink);
  font-weight: 500;
  transition: color 0.15s;
}

/* ── Toolbox (funcionalidades / ferramentas) ──────────────────────── */

.apurei-toolbox {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px 0;
}

.apurei-tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 11px 4px 8px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-ink);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
}

.apurei-tool-chip:hover {
  background: #f5f5f3;
  border-color: #c0b8a8;
}

/* Em breve: borda tracejada (serrilhada) — ainda não disponível */
.apurei-tool-chip--soon {
  color: var(--c-muted);
  border-style: dashed;
  border-color: #c8c4bc;
  background: #fafaf8;
  cursor: default;
}

.apurei-tool-chip--soon:hover {
  background: #f5f5f2;
  border-color: #b8b4ac;
  color: var(--c-muted);
}

/* Botão "+" para adicionar ferramentas */
.apurei-tool-chip--add {
  border-style: dashed;
  border-color: #d0ccc6;
  color: var(--c-muted);
  font-size: 16px;
  padding: 2px 10px;
  line-height: 1.2;
}

.apurei-tool-chip--add:hover {
  color: var(--c-ink);
  border-color: #b0a898;
  background: #f5f5f3;
}

.apurei-tool-chip-icon {
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.apurei-tool-chip-label {
  line-height: 1;
}

/* ── Submit row: filter chips + circular send button ─────────────── */

.apurei-submit-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 16px 14px;
}

.apurei-filter-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.apurei-filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 13px;
  border: 1px solid var(--c-border);
  border-radius: 999px;
  background: #fff;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  white-space: nowrap;
  line-height: 1.4;
  user-select: none;
}

.apurei-filter-chip:hover {
  background: #f0ede8;
  border-color: #c0b8a8;
  color: var(--c-ink);
}

.apurei-filter-chip.active {
  background: var(--c-ink);
  border-color: var(--c-ink);
  color: #fff;
}

/* .apurei-send-btn — definido na seção ZONA A acima com especificidade correta */

/* ============================================================
   POPUP DE REVISÃO DE LANÇAMENTOS (ApureiRevisionPopup)
   ============================================================ */

/* ── Botão "Editar" abaixo de cada cartão de mês ─────────────────────── */

.apurei-edit-mes-btn {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 4px 0;
  font-size: 11px;
  font-family: inherit;
  background: none;
  border: 1px solid var(--c-border);
  border-radius: 3px;
  cursor: pointer;
  color: var(--c-muted);
  text-align: center;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  line-height: 1.5;
}
.apurei-edit-mes-btn:hover {
  border-color: var(--c-ink);
  color: var(--c-ink);
  background: var(--c-bg);
}

/* ── Overlay fullscreen ──────────────────────────────────────────────── */
/*
 * O overlay é criado via document.body.appendChild() — fora de .apurei-root.
 * Por isso todas as CSS custom properties e resets precisam ser re-declarados
 * aqui, caso contrário não cascateiam para os elementos do modal.
 */

.apurei-rev-overlay {
  /* ── Re-declara tokens (espelho do .apurei-root) ── */
  --c-bg:        #f5f5f3;
  --c-surface:   #ffffff;
  --c-ink:       #111111;
  --c-muted:     #666666;
  --c-border:    #e0ddd8;
  --c-ok:        #1a6b3c;
  --c-ok-bg:     #eaf4ee;
  --c-warn:      #7a4f00;
  --c-warn-bg:   #fef3dc;
  --c-error:     #7a1a1a;
  --c-error-bg:  #fdecea;
  --c-step-done: #1a6b3c;
  --radius:      3px;
  --shadow:      0 1px 3px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.04);
  --font-serif:  'Lora', Georgia, serif;
  --font-mono:   'JetBrains Mono', 'Courier New', monospace;
  --font-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* ── Layout do overlay ── */
  position: fixed;
  inset: 0;
  z-index: 99998;
  background: rgba(17, 17, 17, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  transition: opacity 0.2s ease;

  /* ── Herança de fonte para todos os descendentes ── */
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--c-ink);
  line-height: 1.5;
}

.apurei-rev-overlay.open { opacity: 1; }

/* Reset de box-model para todos os elementos dentro do modal */
.apurei-rev-overlay *,
.apurei-rev-overlay *::before,
.apurei-rev-overlay *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* Reset de buttons dentro do modal */
.apurei-rev-overlay button {
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  border: initial;
  background: initial;
  color: inherit;
}

/* Re-aplica herança de fonte a inputs/selects dentro do modal */
.apurei-rev-overlay input,
.apurei-rev-overlay select,
.apurei-rev-overlay textarea {
  font-family: inherit;
  font-size: inherit;
}

/* Toggle input: esconde o checkbox nativo (modal está fora de .apurei-root,
   então a regra original .apurei-root .apurei-toggle input não casa aqui).
   NÃO usar pointer-events: none — isso impede o label de despachar o clique
   para o input, quebrando o toggle. */
.apurei-rev-overlay .apurei-toggle > input {
  opacity: 0 !important;
  width: 0 !important;
  height: 0 !important;
  position: absolute !important;
}

/* ── Modal ──────────────────────────────────────────────────────────── */

.apurei-rev-modal {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 1140px;
  height: calc(100vh - 32px);
  max-height: 920px;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  overflow: hidden;
  transform: translateY(14px);
  transition: transform 0.2s ease;
}
.apurei-rev-overlay.open .apurei-rev-modal { transform: translateY(0); }

/* ── Cabeçalho ────────────────────────────────────────────────────── */

.apurei-rev-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.apurei-rev-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-ink);
}
.apurei-rev-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--c-muted);
  font-size: 15px;
  padding: 4px 8px;
  border-radius: 3px;
  line-height: 1;
  font-family: inherit;
  transition: color 0.15s;
}
.apurei-rev-close:hover { color: var(--c-ink); }

/* ── Corpo (imagem + sidebar) ─────────────────────────────────────── */

.apurei-rev-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  min-height: 0;
}

.apurei-rev-loading {
  flex: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--c-muted);
  font-size: 14px;
}

/* Spinner giratório no loading do modal */
.apurei-rev-loading::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--c-border);
  border-top-color: var(--c-ink);
  border-radius: 50%;
  animation: apurei-spin 0.65s linear infinite;
  flex-shrink: 0;
}

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

.apurei-rev-content {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

/* Painel da imagem PDF — agora contém toolbar + canvas */
.apurei-rev-image-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
  border-right: 1px solid var(--c-border);
}

/* Toolbar de ferramentas do canvas */
.apurei-rev-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #1a1d27;
  border-bottom: 1px solid #2d3148;
  flex-shrink: 0;
}
.apurei-tool-btn {
  padding: 4px 10px;
  border: none;
  border-radius: 5px;
  font-size: 11px;
  cursor: pointer;
  background: transparent;
  color: #94a3b8;
  font-family: inherit;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
}
.apurei-tool-btn:hover { background: #252840; color: #e2e8f0; }
.apurei-tool-btn--active { background: #1e3a5f !important; color: #60a5fa !important; }
.apurei-tool-hint {
  font-size: 10px;
  color: #475569;
  margin-left: auto;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Navegação de páginas do mês dentro do toolbar */
.apurei-rev-page-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: 12px;
  padding-left: 12px;
  border-left: 1px solid #2d3748;
}
#apurei-rev-page-indicator {
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  min-width: 60px;
  text-align: center;
}
.apurei-rev-page-nav .apurei-tool-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Área de scroll do canvas */
.apurei-rev-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
}

/* Canvas interativo */
#apurei-rev-canvas {
  display: block;
  border-radius: 4px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.14);
  max-width: 100%;
}

/* Bloco selecionado na sidebar */
.apurei-rev-block--selected {
  border-color: #4f46e5 !important;
  box-shadow: 0 0 0 2px rgba(79,70,229,0.18);
}

/* Sidebar de blocos */
.apurei-rev-sidebar {
  width: 360px;
  min-width: 280px;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
}
.apurei-rev-empty {
  color: var(--c-muted);
  font-size: 13px;
  padding: 16px;
  text-align: center;
}

/* ── Bloco ───────────────────────────────────────────────────────── */

.apurei-rev-block {
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color 0.18s;
}

/* Bloco inativo: cabeçalho esmaecido + data riscada, conteúdo semi-transparente.
   Mantém o toggle visível e clicável para que o usuário possa reativar. */
.apurei-rev-block.inactive {
  border-color: #c8c3bb;
  border-left: 3px solid #c8c3bb;
}
.apurei-rev-block.inactive .apurei-rev-block-header {
  background: #f0ede8;
}
.apurei-rev-block.inactive .apurei-rev-block-date {
  color: var(--c-muted);
  text-decoration: line-through;
  text-decoration-color: #999;
  opacity: 0.7;
}
.apurei-rev-block.inactive .apurei-rev-block-src {
  opacity: 0.6;
}
.apurei-rev-block.inactive .apurei-rev-txs {
  opacity: 0.32;
  pointer-events: none;  /* não deixa clicar nas transações internas de um bloco desativado */
}

.apurei-rev-block-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  transition: background 0.18s;
}
.apurei-rev-block-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--c-ink);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition: color 0.18s;
}
.apurei-rev-block-src {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.apurei-rev-block-src--detected {
  background: #eeebe5;
  color: #888;
}
.apurei-rev-block-src--user {
  background: #e3f2e8;
  color: #2e7d32;
}
.apurei-rev-block-remove {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--c-muted);
  font-size: 14px;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-family: inherit;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}
.apurei-rev-block-remove:hover {
  color: var(--c-error, #7a1a1a);
  background: var(--c-error-bg, #fdecea);
  border-color: rgba(122,26,26,.15);
}

/* ── Transações ──────────────────────────────────────────────────── */

.apurei-rev-txs { padding: 2px 0; }

.apurei-rev-tx {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
  border-bottom: 1px solid #f2f0ec;
  transition: background 0.12s;
  min-height: 34px;
}
.apurei-rev-tx:last-child { border-bottom: none; }
.apurei-rev-tx:hover      { background: #fafaf8; }

/* Transação inativa pelo usuário: menos opaca que o bloco inteiro inativo */
.apurei-rev-tx.inactive {
  opacity: 0.35;
}

.apurei-rev-tx-origem {
  flex: 1;
  color: var(--c-ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  font-size: 12px;
  cursor: default;               /* title nativo mostra o texto completo no hover */
}
.apurei-rev-tx-valor {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}
.apurei-rev-tx-valor.entrada { color: var(--c-ok,    #1a6b3c); }
.apurei-rev-tx-valor.saida   { color: var(--c-error, #7a1a1a); }

/* ── Rodapé ──────────────────────────────────────────────────────── */

.apurei-rev-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.apurei-rev-hint {
  font-size: 12px;
  color: var(--c-muted);
  flex: 1;
  min-width: 180px;
  line-height: 1.5;
}
.apurei-rev-footer-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* Botão "Confirmar edição" desabilitado enquanto loading */
.apurei-rev-commit:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ── Responsivo ──────────────────────────────────────────────────── */

/* Tabela responsiva em mobile: oculta colunas menos essenciais */
@media (max-width: 640px) {
  .apurei-table { table-layout: auto; }
  .apurei-table th:nth-child(1),
  .apurei-table td:nth-child(1) { width: auto; }
  .apurei-table th:nth-child(4),
  .apurei-table td:nth-child(4) { display: none; }   /* oculta Classificação */
  .apurei-table th:nth-child(5) { width: 180px; }
}

@media (max-width: 640px) {
  .apurei-rev-modal      { height: 100dvh; max-height: none; border-radius: 0; }
  .apurei-rev-content    { flex-direction: column; }
  .apurei-rev-image-panel {
    max-height: 240px;
    min-height: 160px;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    border-left: none;
  }
  .apurei-rev-sidebar    { width: 100%; min-width: 0; border-left: none; }
  .apurei-rev-footer     { flex-direction: column; align-items: stretch; padding: 10px 14px; }
  .apurei-rev-footer-actions { justify-content: flex-end; }
  .apurei-rev-hint       { display: none; } /* oculta dica de texto no mobile para ganhar espaço */
}
