/* =========================================================================
   Conversão de Cotação — folha de estilo única
   Tokens de cor validados para daltonismo e contraste nos dois temas.
   ========================================================================= */

:root {
  color-scheme: light;

  --page:        #f9f9f7;
  --surface:     #fcfcfb;
  --surface-alt: #f2f2ee;
  --ink:         #0b0b0b;
  --ink-2:       #52514e;
  --muted:       #898781;
  --grid:        #e1e0d9;
  --baseline:    #c3c2b7;
  --border:      rgba(11, 11, 11, 0.10);

  --serie-1:     #2a78d6;  /* convertido */
  --serie-2:     #eb6834;  /* não convertido */
  --bom:         #0ca30c;
  --critico:     #d03b3b;
  --texto-bom:   #006300;

  --raio:        14px;
  --raio-sm:     9px;
  --sombra:      0 1px 2px rgba(11, 11, 11, .04), 0 8px 24px rgba(11, 11, 11, .06);
  --fonte:       system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --page:        #0d0d0d;
    --surface:     #1a1a19;
    --surface-alt: #232322;
    --ink:         #ffffff;
    --ink-2:       #c3c2b7;
    --muted:       #898781;
    --grid:        #2c2c2a;
    --baseline:    #383835;
    --border:      rgba(255, 255, 255, 0.10);

    --serie-1:     #3987e5;
    --serie-2:     #d95926;
    --texto-bom:   #0ca30c;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --page:        #0d0d0d;
  --surface:     #1a1a19;
  --surface-alt: #232322;
  --ink:         #ffffff;
  --ink-2:       #c3c2b7;
  --muted:       #898781;
  --grid:        #2c2c2a;
  --baseline:    #383835;
  --border:      rgba(255, 255, 255, 0.10);

  --serie-1:     #3987e5;
  --serie-2:     #d95926;
  --texto-bom:   #0ca30c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--fonte);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ------------------------------------------------------------- cabeçalho -- */

.topo {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

/* O SVG do logo é bem largo (proporção ~7:1); sem o teto de largura ele
   sozinho ocupa metade da tela de um celular. */
.topo__logo {
  height: 30px;
  width: auto;
  max-width: 190px;
  object-fit: contain;
  flex: none;
}

/* min-width: 0 é o que permite o título encolher — sem isso o bloco de texto
   mantém a largura do conteúdo e empurra os botões para fora da tela. */
.topo__info { flex: 1 1 auto; min-width: 0; }

.topo__titulo {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topo__sub {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topo__acoes { display: flex; align-items: center; gap: 8px; flex: none; }

/* ---------------------------------------------------------------- botões -- */

.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--border);
  border-radius: var(--raio-sm);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.botao:hover { background: var(--surface-alt); }
.botao:active { transform: translateY(1px); }

.botao:focus-visible {
  outline: 2px solid var(--serie-1);
  outline-offset: 2px;
}

.botao--primario {
  background: var(--serie-1);
  border-color: var(--serie-1);
  color: #fff;
  width: 100%;
  font-weight: 600;
}

.botao--primario:hover {
  background: color-mix(in srgb, var(--serie-1) 88%, #000);
}

.botao--icone { padding: 0 11px; }

/* ----------------------------------------------------------------- layout -- */

.pagina {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 24px 72px;
}

.secao { margin-top: 34px; }

.carimbo {
  font-size: 12.5px;
  color: var(--muted);
  margin: -6px 0 18px;
}

.secao__titulo {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

/* ------------------------------------------------------------ número herói -- */

.heroi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 26px 28px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 32px;
}

.heroi__rotulo {
  font-size: 13.5px;
  color: var(--ink-2);
  margin: 0 0 4px;
}

.heroi__valor {
  font-size: 54px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.025em;
  margin: 0;
}

.heroi__nota {
  font-size: 13px;
  color: var(--muted);
  margin: 6px 0 0;
  max-width: 46ch;
}

/* ------------------------------------------------------------- cards KPI -- */

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(180px, 100%), 1fr));
  gap: 14px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 17px 19px;
}

.kpi__rotulo {
  font-size: 12.5px;
  color: var(--ink-2);
  margin: 0 0 9px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.kpi__valor {
  /* Encolhe sozinho para "R$ 251.769,82" não quebrar em duas linhas. */
  font-size: clamp(21px, 2.1vw, 26px);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
  margin: 0;
  white-space: nowrap;
}

.kpi__nota {
  font-size: 12.5px;
  color: var(--muted);
  margin: 5px 0 0;
}

.ponto {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
  display: inline-block;
}

.ponto--1 { background: var(--serie-1); }
.ponto--2 { background: var(--serie-2); }

/* ---------------------------------------------------------------- medidor -- */

.medidor {
  height: 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--serie-1) 17%, var(--surface-alt));
  overflow: hidden;
  margin-top: 11px;
}

.medidor__preenchido {
  height: 100%;
  border-radius: 999px;
  background: var(--serie-1);
}

/* --------------------------------------------------------------- gráficos -- */

.graficos {
  /* 420px garante 2 colunas no desktop — com 340px sobrava uma coluna vazia
     ao lado dos cards quando um deles ocupava a linha inteira. */
  /* min() impede que a largura mínima da coluna estoure a tela no celular. */
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: 20px 22px 22px;
}

.card--largo { grid-column: 1 / -1; }

.card__titulo {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 3px;
  letter-spacing: -0.01em;
}

.card__sub {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 16px;
}

/* O container cresce com o conteúdo para o eixo X nunca ficar cortado. */
.card__grafico {
  position: relative;
  width: 100%;
  min-height: 240px;
}

.legenda {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--ink-2);
}

.legenda li { display: flex; align-items: center; gap: 7px; }

.legenda__chave {
  width: 11px;
  height: 11px;
  border-radius: 3px;
  flex: none;
}

/* ---------------------------------------------------------------- tabela -- */

.tabela-area {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--raio);
  background: var(--surface);
  box-shadow: var(--sombra);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 11px 13px;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid var(--grid);
}

th:first-child, td:first-child {
  text-align: left;
  white-space: normal;
  min-width: 146px;
  padding-left: 16px;
}

th:last-child, td:last-child { padding-right: 16px; }

thead th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--surface-alt);
  border-bottom: 1px solid var(--baseline);
  position: sticky;
  top: 0;
}

tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: color-mix(in srgb, var(--serie-1) 5%, transparent); }

tfoot td {
  font-weight: 600;
  background: var(--surface-alt);
  border-top: 1px solid var(--baseline);
  border-bottom: 0;
}

tfoot tr:hover td { background: var(--surface-alt); }

.destaque-eu td {
  background: color-mix(in srgb, var(--serie-1) 9%, transparent);
  font-weight: 600;
}

.destaque-eu td:first-child { box-shadow: inset 3px 0 0 var(--serie-1); }

/* ------------------------------------------------------------------ login -- */

.login {
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  place-items: center;
  padding: 24px;
  position: relative;
}

.login__marca {
  position: absolute;
  top: 26px;
  left: 26px;
  height: 34px;
  width: auto;
}

.login__caixa {
  width: 100%;
  max-width: 372px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--sombra);
  padding: 34px 32px;
}

.login__titulo {
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0 0 5px;
}

.login__sub {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 24px;
}

.campo { margin-bottom: 16px; }

.campo__rotulo {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-2);
  margin-bottom: 7px;
}

.campo__entrada {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--baseline);
  border-radius: var(--raio-sm);
  background: var(--page);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
}

.campo__entrada:focus {
  outline: none;
  border-color: var(--serie-1);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--serie-1) 22%, transparent);
}

.aviso {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 11px 13px;
  border-radius: var(--raio-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
  background: color-mix(in srgb, var(--critico) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--critico) 38%, transparent);
  color: var(--ink);
}

.aviso__icone { flex: none; margin-top: 1px; }

.campo__dica {
  font-size: 12.5px;
  color: var(--muted);
  margin: 7px 0 0;
  line-height: 1.45;
}

select.campo__entrada {
  appearance: none;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
                    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

textarea.campo__entrada {
  min-height: 120px;
  padding: 12px 14px;
  line-height: 1.5;
  resize: vertical;
}

.codigo {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
}

/* ---------------------------------------------------------- formulários -- */

.formulario__linha {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr));
  gap: 0 16px;
}

/* ------------------------------------------------------------- etiquetas -- */

.etiqueta {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--ink-2);
}

.etiqueta--ok {
  background: color-mix(in srgb, var(--bom) 15%, transparent);
  border-color: color-mix(in srgb, var(--bom) 40%, transparent);
  color: var(--texto-bom);
}

.etiqueta--alerta {
  background: color-mix(in srgb, var(--critico) 13%, transparent);
  border-color: color-mix(in srgb, var(--critico) 40%, transparent);
  color: var(--ink);
}

.fraco { color: var(--muted); }

.lista-nomes {
  list-style: none;
  margin: 0 0 18px;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr));
  gap: 7px 18px;
  font-size: 14px;
}

.lista-nomes li { display: flex; align-items: center; gap: 9px; }

.dados-lista {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(190px, 100%), 1fr));
  gap: 14px 22px;
  margin: 0 0 16px;
}

.dados-lista dt {
  font-size: 12.5px;
  color: var(--muted);
  margin-bottom: 4px;
}

.dados-lista dd {
  margin: 0;
  font-size: 14.5px;
  font-weight: 500;
}

.senha-revelada {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .04em;
  user-select: all;
  padding: 3px 9px;
}

/* ------------------------------------------------- tabela de administração -- */

.celula-texto { text-align: left; white-space: normal; }
.celula-acoes { text-align: left; white-space: nowrap; }

.acoes-linha {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.botao--pequeno {
  min-height: 30px;
  padding: 0 11px;
  font-size: 12.5px;
}

.botao--perigo {
  border-color: color-mix(in srgb, var(--critico) 45%, transparent);
  color: var(--critico);
}

.botao--perigo:hover {
  background: color-mix(in srgb, var(--critico) 12%, transparent);
}

.aviso--ok {
  background: color-mix(in srgb, var(--bom) 11%, transparent);
  border-color: color-mix(in srgb, var(--bom) 38%, transparent);
}

.aviso--nota {
  background: var(--surface-alt);
  border-color: var(--border);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .92em;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.login__rodape {
  margin-top: 22px;
  padding-top: 17px;
  border-top: 1px solid var(--grid);
  font-size: 12.5px;
  color: var(--muted);
  text-align: center;
}

.login__qr {
  position: absolute;
  right: 30px;
  bottom: 30px;
  width: 116px;
  height: auto;
  opacity: .85;
  border-radius: 10px;
}

/* -------------------------------------------------------------- utilitários -- */

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

.positivo { color: var(--texto-bom); }

.vazio {
  padding: 44px 22px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 900px) {
  .login__qr { display: none; }
}

@media (max-width: 720px) {
  .pagina { padding: 20px 15px 56px; }
  .topo { padding: 11px 15px; gap: 11px; }
  .topo__logo { height: 24px; max-width: 104px; }
  .topo__sub { display: none; }
  .heroi__valor { font-size: 41px; }
  .heroi { padding: 21px; }
  .card { padding: 17px 15px 18px; }
}

@media print {
  .topo__acoes, .login__qr { display: none; }
  body { background: #fff; }
  .card, .kpi, .heroi, .tabela-area { box-shadow: none; }
}
