/* Design system SIMPLE ENERGY — pt-BR, WCAG 2.1 AA (FR-019a/SC-009, FR-039).
   Identidade: Persian Indigo #330072 (primária) + Carolina Blue #009CDE (secundária),
   tipografia Exo, texto em roxo escuro (a marca não usa preto puro).
   Regra de contraste: texto normal usa --ink/--indigo (>= 7:1 sobre branco); o ciano
   só aparece em texto GRANDE (valores de KPI, >= 18px bold → AA 3:1) ou em acentos. */

:root {
  /* Marca */
  --indigo: #330072;            /* primária — ~12:1 sobre branco */
  --indigo-hover: #4a1a9e;      /* ~7:1 — estados hover/active */
  --blue: #009CDE;              /* secundária — só texto grande/acento */
  --ink: #241147;               /* texto — roxo escuro, ~14:1 sobre branco */
  --muted: #5c5c6a;             /* texto secundário — ~6:1 */
  --line: #e6e3ee;              /* bordas finas */
  --bg: #f6f5fa;                /* fundo da página */
  --surface: #ffffff;           /* cartões / cabeçalho */
  /* Semânticos (estados) — mantidos distintos para clareza + AA */
  --erro: #b00020;              /* ~6:1 */
  --erro-bg: #fdecea;
  --sucesso: #146c43;           /* ~5:1 */
  --sucesso-bg: #e7f4ee;
  --ambar: #6a4b00;             /* ~6.7:1 — "em processamento" */
  --foco: 3px solid #330072;
  /* Elevação (Figma: cartões sem borda, sombra suave) */
  --sombra: 0 1px 3px rgba(36, 17, 71, .10), 0 1px 2px rgba(36, 17, 71, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Exo", "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 15px;
}

h1, h2, h3 { color: var(--indigo); font-weight: 700; line-height: 1.2; }
h1 { font-size: 24px; margin: 0 0 .6rem; }
h2 { font-size: 19px; margin: 1.4rem 0 .5rem; }
h3 { font-size: 16px; }
p { margin: .5rem 0; }

a { color: var(--indigo); text-decoration: underline; }
a:hover { color: var(--indigo-hover); }

/* Foco visível consistente (WCAG 2.4.7) */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: var(--foco);
  outline-offset: 2px;
}

/* Conteúdo só para leitores de tela (nome acessível de ícones) */
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.scroll-x { overflow-x: auto; }

/* Skip link (WCAG 2.4.1) */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--indigo);
  color: #fff;
  padding: 0.5rem 1rem;
  z-index: 10;
}
.skip-link:focus { left: 0; }

/* ----- Shell ----- */
.site-header {
  background: var(--surface);
  border-bottom: 3px solid var(--indigo);
  padding: .9rem 0;
}
.site-header .inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
}
.site-header .brand { display: inline-flex; line-height: 0; }
.site-header .logo { height: 40px; width: auto; }

.site-main { max-width: 760px; margin: 1.4rem auto; padding: 0 1.5rem 2.5rem; }
.painel-wide .site-main { max-width: 1040px; }

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--surface);
  padding: 1rem 1.5rem;
  color: var(--muted);
  text-align: center;
}
.site-footer .footer-contatos { margin: 0 0 0.35rem; font-size: 14px; }
.site-footer .footer-contatos a { color: var(--indigo); font-weight: 600; text-decoration: none; }
/* :not(.btn) — o sublinhado de hover é affordance de LINK; o pill do WhatsApp fica fora. */
.site-footer .footer-contatos a:not(.btn):hover,
.site-footer .footer-contatos a:not(.btn):focus-visible { text-decoration: underline; }
.site-footer .footer-contatos span { margin: 0 0.5rem; color: var(--muted); }
.site-footer .btn--wa { vertical-align: middle; }

/* WhatsApp (FR-048, 2026-08-06): telefone é botão que abre conversa. Especificidade
   .btn.btn--wa (e margin-top: 0) para vencer o `button, .btn` declarado mais abaixo —
   o pill vive INLINE em texto corrido (rodapé/callouts), não como botão de formulário. */
.btn.btn--wa {
  padding: 6px 14px; font-size: 13.5px; white-space: nowrap;
  margin-top: 0;
  color: #fff !important; text-decoration: none !important;
}
.btn.btn--wa:hover, .btn.btn--wa:focus-visible { color: #fff !important; }

/* ----- Estados das análises (FR-045/047): oportunidade em DESTAQUE × tudo ok ----- */
.callout {
  display: flex; gap: 0.6rem; align-items: flex-start;
  border-radius: 0 10px 10px 0; padding: 0.85rem 1.1rem; margin-top: 0.9rem;
  font-size: 14.5px; line-height: 1.55;
}
.callout--oportunidade {
  background: #eef4fb; border-left: 4px solid var(--blue);
  color: var(--ink); font-weight: 600;
}
.callout--oportunidade .icone { font-size: 1.25rem; line-height: 1.2; }
.callout--oportunidade .btn--wa { margin-left: 0.15rem; }
.callout--ok {
  background: var(--sucesso-bg); border-left: 4px solid var(--sucesso);
  color: var(--sucesso); font-weight: 600; margin-bottom: 0;
}

/* ----- Seções viram cartões (páginas de conteúdo) ----- */
.site-main > section {
  background: var(--surface);
  border: none;
  box-shadow: var(--sombra);
  border-radius: 12px;
  padding: 1.3rem 1.5rem;
  margin-bottom: 1.1rem;
}
.site-main > section > h1:first-child,
.site-main > section > h2:first-child { margin-top: 0; }

.meta { color: var(--muted); font-size: 13px; }
.sec-title {
  color: var(--indigo); font-weight: 700; font-size: 12px; letter-spacing: .08em;
  text-transform: uppercase; margin: 1.5rem 0 .6rem;
}
.card {
  background: var(--surface); border: none; box-shadow: var(--sombra);
  border-radius: 12px; padding: 1rem 1.2rem;
}

/* ----- Mensagens do framework `messages` ----- */
.messages { list-style: none; padding: 0; margin: 1.1rem auto; max-width: 760px; }
.painel-wide .messages { max-width: 1040px; }
.message { padding: .75rem 1rem; border-radius: 8px; margin: .6rem 0; }
.message--error { background: var(--erro-bg); color: var(--erro); border: 1px solid var(--erro); }
.message--success { background: var(--sucesso-bg); color: var(--sucesso); border: 1px solid var(--sucesso); }
.message--info { background: #eef4fb; color: var(--indigo); border: 1px solid #c9d8ec; }

/* ----- Estados por conta/lote (texto sempre acompanha a cor — WCAG 1.4.1) ----- */
.estado { font-weight: 700; }
.estado--processing { color: var(--ambar); }
.estado--report_ready, .estado--report_reused, .estado--extracted { color: var(--sucesso); }
.estado--report_failed, .estado--failed { color: var(--erro); }
.estado--duplicate { color: var(--muted); }

/* ----- Formulários acessíveis ----- */
.field { margin-top: 1rem; }
label { display: block; font-weight: 600; color: var(--ink); margin-bottom: .3rem; }
input, select, textarea {
  width: 100%;
  padding: .55rem .6rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: #fff;
}
input[type="file"] { padding: .45rem; background: var(--bg); }
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px; accent-color: var(--indigo);
  vertical-align: middle; margin: 0;
}
small { display: block; color: var(--muted); font-size: 13px; margin-top: .3rem; }
.field-error { color: var(--erro); font-weight: 600; font-size: .9rem; margin-top: .3rem; }

/* ----- Botões + CTAs (style guide: formato pill) ----- */
button, .btn {
  display: inline-block; margin-top: 1.3rem;
  padding: .6rem 1.6rem;
  background: var(--indigo); color: #fff;
  border: none; border-radius: 999px;
  font-family: inherit; font-size: 1rem; font-weight: 700;
  text-decoration: none; cursor: pointer;
}
button:hover, .btn:hover { background: var(--indigo-hover); }
/* Variante outline do guide (Botões.png) — ainda sem uso nos templates; manter disponível. */
.btn--outline {
  background: transparent; color: var(--indigo);
  border: 2px solid var(--indigo);
}
.btn--outline:hover { background: #f1edf8; }
.cta { display: inline-block; margin-top: .8rem; font-weight: 700; }

/* ----- Listas de lotes/contas ----- */
ul.bills { list-style: none; padding: 0; margin: .4rem 0 0; }
ul.bills li { padding: .55rem 0; border-bottom: 1px solid var(--line); }
ul.bills li:last-child { border-bottom: none; }

/* ----- Componentes do painel consolidado (dashboard.html estende base) ----- */
.kpis { display: flex; flex-wrap: wrap; gap: 12px; }
.kpi { flex: 1 1 165px; background: var(--surface); border: none; box-shadow: var(--sombra);
       border-radius: 12px; padding: .8rem 1rem; }
.kpi .v { color: var(--blue); font-weight: 700; font-size: 22px; line-height: 1.15; }
.kpi .v.neg { color: var(--erro); }  /* Figma: variação negativa em vermelho */
.faturas .neg { color: var(--erro); }  /* custos evitáveis: total em vermelho (mesma semântica) */
.kpi .l { color: var(--muted); font-size: 12px; margin-top: .25rem; }

table.faturas { border-collapse: collapse; width: 100%; font-size: 13px; }
table.faturas thead th { background: var(--indigo); color: #fff; font-weight: 700;
                         text-align: left; padding: .55rem .7rem; }
table.faturas thead th.num { text-align: right; }
table.faturas td { padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
table.faturas td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.faturas td.mes { color: var(--indigo); font-weight: 700; }  /* indigo: AA em texto normal (ciano falharia) */
table.faturas tbody tr:last-child td { border-bottom: none; }
tr.row-falha td { background: var(--erro-bg); }  /* Figma: linha com falha rosada */
/* Status em círculos preenchidos (Figma) — glifo branco sobre fundo semântico */
.ok, .x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  color: #fff; font-size: 11px; font-weight: 700; line-height: 1;
}
.ok { background: var(--sucesso); }
.x { background: var(--erro); }
.viz { margin: .4rem 0; }
.empty { color: var(--muted); }

.filtros { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
           background: var(--surface); border: none; box-shadow: var(--sombra);
           border-radius: 12px; padding: .8rem 1rem; margin: 1.1rem 0; }
.filtros label { display: flex; flex-direction: column; gap: .25rem; font-size: 12px;
                 color: var(--muted); font-weight: 600; margin: 0; }
.filtros select, .filtros input { font-size: 14px; }
.filtros button { margin-top: 0; padding: .5rem 1.1rem; }
.filtros .limpar { color: var(--muted); font-size: 13px; align-self: center; }

@media (max-width: 640px) {
  .site-header .inner, .site-main { padding-left: 1rem; padding-right: 1rem; }
}
