/*
 * imobot — sistema de desenho da dashboard.
 *
 * Paleta contida: neutros, um acento, quatro semânticas. Sem vidro, sem
 * gradientes, sem sombras pesadas, sem animações decorativas. O que se
 * destaca numa página de anúncios é o preço — nada aqui deve competir
 * com ele.
 */

:root {
  --fundo: #f6f7f9;        --superficie: #ffffff;    --superficie-2: #eef0f3;
  --borda: #dfe3e8;        --texto: #1a1d21;         --texto-suave: #5f6b7a;
  --acento: #0f766e;       --acento-suave: #ccfbf1;  --acento-texto: #ffffff;
  --sucesso: #15803d;      --sucesso-suave: #dcfce7;
  --aviso: #b45309;        --aviso-suave: #fef3c7;
  --perigo: #b91c1c;       --perigo-suave: #fee2e2;
  --info: #1d4ed8;         --info-suave: #dbeafe;
  --raio: 8px;             --raio-pilula: 999px;
  --sombra: 0 1px 2px rgb(0 0 0 / .06), 0 1px 3px rgb(0 0 0 / .04);
  --fonte: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --fonte-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-8: 48px;
  --largura-max: 1200px;
  --altura-cabecalho: 56px;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --fundo: #0f1216;        --superficie: #161a20;    --superficie-2: #1e242c;
    --borda: #2a323c;        --texto: #e6e9ee;         --texto-suave: #98a2b3;
    --acento: #2dd4bf;       --acento-suave: #134e4a;  --acento-texto: #06201d;
    --sucesso: #4ade80;      --sucesso-suave: #14532d;
    --aviso: #fbbf24;        --aviso-suave: #78350f;
    --perigo: #fca5a5;       --perigo-suave: #7f1d1d;
    --info: #93c5fd;         --info-suave: #1e3a8a;
    --sombra: none;
  }
}

:root[data-theme="dark"] {
  --fundo: #0f1216;        --superficie: #161a20;    --superficie-2: #1e242c;
  --borda: #2a323c;        --texto: #e6e9ee;         --texto-suave: #98a2b3;
  --acento: #2dd4bf;       --acento-suave: #134e4a;  --acento-texto: #06201d;
  --sucesso: #4ade80;      --sucesso-suave: #14532d;
  --aviso: #fbbf24;        --aviso-suave: #78350f;
  --perigo: #fca5a5;       --perigo-suave: #7f1d1d;
  --info: #93c5fd;         --info-suave: #1e3a8a;
  --sombra: none;
}

/* ---------- reset mínimo ---------- */

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

body, h1, h2, h3, h4, p, figure, dl, dd {
  margin: 0;
}

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

body {
  min-width: 360px;
  font-family: var(--fonte);
  font-size: 15px;
  line-height: 1.5;
  color: var(--texto);
  background: var(--fundo);
  font-variant-numeric: tabular-nums;
  padding-top: var(--altura-cabecalho);
}

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

a { color: var(--acento); }

h1, h2, h3, h4 {
  font-weight: 600;
  line-height: 1.25;
}
h1 { font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 16px; }
h4 { font-size: 15px; }

button, input, select, textarea { font-family: inherit; }

:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: 2px solid var(--acento);
  outline-offset: 2px;
  border-radius: 2px;
}

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

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

.texto-suave { color: var(--texto-suave); }
.texto-pequeno { font-size: 13px; }
.numero, .mono { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--fonte-mono); }
.texto-legivel { max-width: 72ch; }

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

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

.contentor {
  max-width: var(--largura-max);
  margin-inline: auto;
  padding-inline: var(--s-4);
}
@media (min-width: 640px) {
  .contentor { padding-inline: var(--s-5); }
}

main.contentor {
  padding-block: var(--s-5) var(--s-8);
  scroll-margin-top: var(--altura-cabecalho);
}

.grelha {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
}
.grelha > * { min-width: 0; }

.grelha--2 { grid-template-columns: 1fr; }
.grelha--3 { grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grelha--2 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 860px) {
  .grelha--3 { grid-template-columns: repeat(3, 1fr); }
}
.grelha--auto {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.pilha {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
}

.pilha-apertada {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
}

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

.cabecalho {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  z-index: 10;
  height: var(--altura-cabecalho);
  background: var(--superficie);
  border-bottom: 1px solid var(--borda);
  box-shadow: var(--sombra);
}
.cabecalho .contentor {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  height: 100%;
}

.cabecalho__marca {
  flex-shrink: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--texto);
  text-decoration: none;
  letter-spacing: -.01em;
  cursor: pointer;
}

.navegacao {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.navegacao__item {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding-inline: var(--s-2);
  font-size: 14px;
  font-weight: 500;
  color: var(--texto-suave);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.navegacao__item:hover {
  color: var(--texto);
}
.navegacao__item--activo {
  color: var(--texto);
  border-bottom-color: var(--acento);
  font-weight: 600;
}

.cabecalho__accoes {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}

.entrar {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: 6px var(--s-3);
  border-radius: var(--raio-pilula);
  background: var(--acento);
  color: var(--acento-texto);
  border: none;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity .12s ease;
}
.entrar:hover { opacity: .9; }

.rodape {
  border-top: 1px solid var(--borda);
  padding-block: var(--s-5);
  color: var(--texto-suave);
  font-size: 13px;
}

/* ---------- cartão ---------- */

.cartao {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
}

.cartao__cabecalho {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-4) 0;
}

.cartao__cabecalho.cartao__cabecalho--empilhado {
  flex-direction: column;
  align-items: flex-start;
  gap: var(--s-1);
}

.cartao__titulo {
  font-size: 16px;
  font-weight: 600;
}

.cartao__corpo {
  padding: var(--s-4);
}

/* ---------- etiqueta ---------- */

.etiqueta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px var(--s-2);
  border-radius: var(--raio-pilula);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}
.etiqueta--sucesso { background: var(--sucesso-suave); color: var(--sucesso); }
.etiqueta--aviso { background: var(--aviso-suave); color: var(--aviso); }
.etiqueta--perigo { background: var(--perigo-suave); color: var(--perigo); }
.etiqueta--info { background: var(--info-suave); color: var(--info); }
.etiqueta--neutro { background: var(--superficie-2); color: var(--texto); }
.etiqueta--acento { background: var(--acento-suave); color: var(--acento); }

/* ---------- botão ---------- */

.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-4);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  background: var(--superficie-2);
  color: var(--texto);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
  text-decoration: none;
  cursor: pointer;
  transition: background-color .12s ease, border-color .12s ease, opacity .12s ease;
}
.botao:hover { background: var(--superficie); border-color: var(--texto-suave); }
.botao:disabled { opacity: .55; cursor: not-allowed; }

.botao--primario {
  background: var(--acento);
  border-color: var(--acento);
  color: var(--acento-texto);
}
.botao--primario:hover { opacity: .9; background: var(--acento); border-color: var(--acento); }

.botao--pequeno {
  padding: var(--s-1) var(--s-3);
  font-size: 13px;
}

.botao--perigo {
  background: var(--perigo);
  border-color: var(--perigo);
  color: #fff;
}
.botao--perigo:hover { opacity: .9; }

/* ---------- campo / formulário de filtros ---------- */

.campo {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  min-width: 0;
}

.campo__rotulo {
  font-size: 13px;
  font-weight: 500;
  color: var(--texto-suave);
}

.campo__entrada {
  width: 100%;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  background: var(--superficie-2);
  color: var(--texto);
  font-size: 14px;
  line-height: 1.5;
}
.campo__entrada::placeholder { color: var(--texto-suave); }

.formulario-filtros {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(155px, 1fr));
  gap: var(--s-3) var(--s-4);
  align-items: end;
}

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

.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.tabela th, .tabela td {
  padding: var(--s-3);
  text-align: left;
  border-bottom: 1px solid var(--borda);
  vertical-align: middle;
}
.tabela th {
  color: var(--texto-suave);
  font-weight: 600;
  font-size: 13px;
}
.tabela th.numero, .tabela td.numero {
  text-align: right;
}
.tabela tbody tr:hover { background: var(--superficie-2); }
.tabela tbody tr:last-child td { border-bottom: none; }

.tabela--compacta th, .tabela--compacta td {
  padding: var(--s-2);
}

.tabela-rolavel {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--borda);
  border-radius: var(--raio);
}
.tabela-rolavel .tabela { border: none; }
.tabela-rolavel .tabela th:first-child,
.tabela-rolavel .tabela td:first-child { padding-inline-start: var(--s-4); }
.tabela-rolavel .tabela th:last-child,
.tabela-rolavel .tabela td:last-child { padding-inline-end: var(--s-4); }

.quadro__valor { white-space: nowrap; }
.quadro__barra { width: 110px; min-width: 80px; }
.quadro__fina td { color: var(--texto-suave); }

/* ---------- estatística ---------- */

.estatistica {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.estatistica__valor {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
}
.estatistica__rotulo {
  font-size: 13px;
  color: var(--texto-suave);
}
.estatistica__nota {
  font-size: 12px;
  color: var(--texto-suave);
}

/* ---------- barra de progresso ---------- */

.barra {
  width: 100%;
  height: 8px;
  border-radius: var(--raio-pilula);
  background: var(--superficie-2);
  overflow: hidden;
}
.barra__preenchimento {
  height: 100%;
  min-width: 2px;
  background: var(--acento);
  border-radius: var(--raio-pilula);
}

/* ---------- aviso ---------- */

.aviso {
  padding: var(--s-3) var(--s-4);
  border: 1px solid transparent;
  border-radius: var(--raio);
  font-size: 14px;
  line-height: 1.5;
}
.aviso--info { background: var(--info-suave); color: var(--info); border-color: var(--info); }
.aviso--atencao { background: var(--aviso-suave); color: var(--aviso); border-color: var(--aviso); }
.aviso--erro { background: var(--perigo-suave); color: var(--perigo); border-color: var(--perigo); }
.aviso--sucesso { background: var(--sucesso-suave); color: var(--sucesso); border-color: var(--sucesso); }

/* ---------- anúncio (linha da lista) ---------- */

.anuncio {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding-block: var(--s-4);
  border-bottom: 1px solid var(--borda);
}
.anuncio:first-child { padding-block-start: 0; }
.anuncio:last-child { border-bottom: none; padding-block-end: 0; }

.anuncio__imagem {
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: var(--raio);
  background: var(--superficie-2);
  color: var(--texto-suave);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  object-fit: cover;
}

.anuncio__corpo {
  display: flex;
  flex-direction: column;
  gap: var(--s-1);
  min-width: 0;
  flex: 1 1 auto;
}

.anuncio__titulo {
  font-size: 15px;
  font-weight: 600;
  color: var(--texto);
  text-decoration: none;
  cursor: pointer;
}
.anuncio__titulo:hover { text-decoration: underline; }

.anuncio__meta {
  font-size: 13px;
  color: var(--texto-suave);
}

.anuncio__preco {
  font-size: 20px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--texto);
}
.anuncio__preco .texto-suave,
.anuncio__preco .texto-pequeno {
  font-weight: 400;
}
.anuncio__preco--grande {
  font-size: 32px;
}

.anuncio__etiquetas {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-1);
  margin-top: 2px;
}

@media (min-width: 640px) {
  .anuncio {
    flex-direction: row;
    align-items: flex-start;
  }
  .anuncio__imagem {
    width: 128px;
    height: 94px;
    aspect-ratio: auto;
    flex-shrink: 0;
  }
  .anuncio__preco {
    flex-shrink: 0;
    text-align: right;
    margin-inline-start: auto;
  }
}

.anuncio__imagem--grande {
  width: 100%;
  height: auto;
  max-height: 400px;
  aspect-ratio: auto;
  object-fit: cover;
  border-radius: var(--raio);
  flex-shrink: 0;
}

/* ---------- «Como se compara» (ficha do anúncio) ---------- */

.leitura {
  padding: var(--s-4);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  background: var(--superficie);
  min-width: 0;
}
.leitura__titulo {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.posicionamento {
  display: block;
  width: 100%;
  max-width: 340px;
  height: auto;
}
.posicionamento__eixo { stroke: var(--borda); stroke-width: 2; stroke-linecap: round; }
.posicionamento__faixa { fill: var(--superficie-2); }
.posicionamento__caixa { fill: var(--acento-suave); }
.posicionamento__mediana { stroke: var(--texto-suave); stroke-width: 2; }
.posicionamento__ponto { fill: var(--texto-suave); opacity: .35; }
.posicionamento__anuncio { stroke: var(--acento); stroke-width: 2.5; stroke-linecap: round; }
.posicionamento__anuncio-ponto { fill: var(--acento); stroke: var(--superficie); stroke-width: 1.5; }

.posicionamento__legenda {
  display: flex;
  justify-content: space-between;
  gap: var(--s-2);
  max-width: 340px;
}

/* ---------- ficha do anúncio: cabeçalho ---------- */

.ficha-topo {
  display: grid;
  gap: var(--s-4);
  min-width: 0;
}
@media (min-width: 860px) {
  .ficha-topo--com-foto {
    grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
    gap: var(--s-5);
    align-items: start;
  }
}
@media (max-width: 859px) {
  .ficha-topo .anuncio__imagem--grande { max-height: 240px; }
}

.ficha-topo__corpo {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  min-width: 0;
}

.ficha-topo__identidade {
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
}

.ficha-topo__titulo {
  font-size: 22px;
  line-height: 1.25;
  overflow-wrap: break-word;
}

.ficha-topo__preco {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--s-2) var(--s-3);
  min-width: 0;
}
.ficha-topo__preco .anuncio__preco {
  margin-inline-start: 0;
  text-align: start;
}

.factos {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: var(--s-3) var(--s-4);
  min-width: 0;
}

.factos__item {
  min-width: 0;
  padding-top: var(--s-2);
  border-top: 1px solid var(--borda);
}

.factos__rotulo {
  font-size: 12px;
  color: var(--texto-suave);
}

.factos__valor {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.historico {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.historico__linha {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-4);
  padding-block: var(--s-2);
  border-bottom: 1px solid var(--borda);
}
.historico__linha:last-child { border-bottom: none; }

.historico__data {
  font-size: 13px;
  color: var(--texto-suave);
}

.historico__valor {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

/* ---------- vistas e consola de logs ---------- */

.vista { display: none; }
.vista.activa { display: block; }

.log-terminal {
  background: var(--superficie-2);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  padding: var(--s-3);
  font-family: var(--fonte-mono);
  font-size: 12.5px;
  line-height: 1.5;
  max-height: 420px;
  overflow-y: auto;
  color: var(--texto);
}
.log-linha { padding-block: 2px; border-bottom: 1px solid var(--borda); }
.log-linha:last-child { border-bottom: none; }
.log-linha.erro { color: var(--perigo); }
.log-linha.sucesso { color: var(--sucesso); }

/* ---------- modal simples ---------- */

.modal-fundo {
  position: fixed;
  inset: 0;
  background: rgb(0 0 0 / .45);
  display: none;
  align-items: center;
  justify-content: center;
  padding: var(--s-4);
  z-index: 50;
}
.modal-fundo.activo { display: flex; }

.modal-caixa {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  width: 100%;
  max-width: 380px;
  padding: var(--s-5);
}

/* ---------- notificações discretas ---------- */

.notificacoes {
  position: fixed;
  bottom: var(--s-4);
  right: var(--s-4);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
}

.notificacao {
  background: var(--superficie);
  border: 1px solid var(--borda);
  border-radius: var(--raio);
  box-shadow: var(--sombra);
  padding: var(--s-2) var(--s-4);
  font-size: 13px;
  font-weight: 500;
  color: var(--texto);
}
