/* Moldura. Superfície principal: 1440×900 no portátil, 1194×834 em tablet.

   O ecrã não desliza como um todo: a barra lateral e o cabeçalho ficam fixos e
   só o interior de cada vista desliza. Uma lista de sessenta anúncios que
   empurra o título para fora do ecrã obriga a subir para saber onde se está. */

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: var(--t-body);
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  -webkit-font-smoothing: antialiased;
}

.app { display: flex; height: 100%; overflow: hidden; }
.hidden { display: none !important; }
.spacer { flex: 1; }

/* ---------------------------------------------------------------------------
   Barra lateral
   --------------------------------------------------------------------------- */
.rail {
  width: 228px; flex: none;
  background: var(--rail);
  color: var(--rail-text);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.rail-topo { padding: 22px var(--s5) 0; }
.marca { display: flex; align-items: center; gap: 9px; }
/* A marca desenhada, nao um quadrado com uma letra. Os tracos herdam o
   `color` da caixa, por isso a barra muda de tema sem se lhe tocar. */
.marca { color: var(--on-dark); }
.marca-m {
  width: 27px; height: 27px; flex: none;
  /* -1px optico: os arcos nao tocam a caixa em cima nem a esquerda, e sem
     isto a marca parece pousada mais abaixo do que o texto ao lado. */
  margin-top: -1px;
}
/* O ponto do radar leva o dourado da app e nao o laranja do ficheiro de
   marca: sao duas cores quentes a 20px uma da outra, e o dourado ja e o
   acento da barra — o item de navegacao activo usa-o. Duas cores de destaque
   lado a lado nao destacam nada.
   Em CSS e nao no atributo `fill`: assim segue o token e muda com o tema. */
.marca-ponto { fill: var(--gold); }
.marca-n {
  font-size: 15px; font-weight: 600; letter-spacing: -0.01em;
  color: var(--on-dark);
}
.marca-sub {
  font-size: var(--m-label); line-height: 1.4; color: var(--rail-dim);
  margin-top: 9px; padding-left: 36px;   /* 27 da marca + 9 do intervalo */
}

.rail-nav { display: flex; flex-direction: column; gap: 2px; padding: 26px var(--s3) 0; }
.rail-item {
  appearance: none; cursor: pointer; text-align: left;
  border: 0; border-radius: var(--r7); background: transparent;
  padding: 11px 13px;
  display: flex; align-items: baseline; gap: 10px;
  transition: background var(--dur) var(--ease);
}
.rail-item:hover { background: var(--rail-hover); }
.rail-item .num {
  font-size: var(--m-micro); font-weight: 500; line-height: 1;
  color: var(--rail-faint); width: 14px; flex: none;
}
.rail-item .corpo { flex: 1; min-width: 0; }
.rail-item .rot {
  display: block; font-size: 13.5px; font-weight: 500; line-height: 1.2;
  color: var(--rail-text);
}
.rail-item .sub {
  display: block; font-size: var(--m-label); line-height: 1.35;
  color: var(--rail-dim); margin-top: var(--s1);
}
.rail-item .badge {
  font-size: var(--m-micro); font-weight: 500; line-height: 1;
  color: var(--rail-dim); flex: none;
}
.rail-item[aria-selected="true"] { background: var(--rail-on); }
.rail-item[aria-selected="true"] .num,
.rail-item[aria-selected="true"] .badge { color: var(--gold); }
.rail-item[aria-selected="true"] .rot { color: var(--on-dark); }
.rail-item[aria-selected="true"] .sub { color: var(--rail-mid); }

.rail-estado {
  margin: 0 var(--s3) 14px; padding: 13px;
  border-radius: var(--r7); background: var(--rail-card);
}
.rail-estado-topo { display: flex; align-items: center; gap: var(--s2); }
.rail-estado .dot-s {
  width: 6px; height: 6px; border-radius: 50%; display: block; flex: none;
  background: var(--rail-faint);
}
.rail-estado .dot-s.on { background: var(--ok); }
.rail-rot {
  font-size: var(--m-micro); font-weight: 500; line-height: 1;
  letter-spacing: 0.09em; text-transform: uppercase; color: var(--rail-mid);
}
.rail-estado-val {
  font-size: var(--m-small); font-weight: 500; line-height: 1;
  color: var(--rail-bright); margin-top: 9px;
}
.rail-estado-sub {
  font-size: var(--m-label); line-height: 1.5; color: var(--rail-dim); margin-top: var(--s2);
  overflow-wrap: anywhere;
}
.rail-estado-accoes { display: flex; gap: var(--s2); margin-top: 10px; }
.rail-btn {
  appearance: none; cursor: pointer; font-family: var(--sans);
  font-size: var(--m-micro); font-weight: 500;
  color: var(--rail-text); background: transparent;
  border: 1px solid var(--rail-faint); border-radius: var(--r5);
  padding: 5px 10px;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.rail-btn:hover { color: var(--gold); border-color: var(--gold); }
.rail-btn[hidden] { display: none; }

.rail-nota {
  padding: 0 var(--s5) var(--s5);
  font-size: var(--m-micro); line-height: 1.55; color: var(--rail-faint);
}

/* ---------------------------------------------------------------------------
   Coluna principal
   --------------------------------------------------------------------------- */
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topo {
  height: 66px; flex: none;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: var(--s5);
  padding: 0 26px;
}
.topo-tit { min-width: 0; }
.topo h1 { font-size: var(--t-title); font-weight: 600; line-height: 1.15; letter-spacing: -0.015em; }
.topo-sub { font-size: 11.5px; color: var(--text3); margin-top: 5px; }
.topo-accoes { display: flex; align-items: center; gap: 10px; }
.topo .sep { width: 1px; height: 22px; background: var(--line); display: block; flex: none; }

.icone {
  appearance: none; cursor: pointer;
  border: 1px solid var(--line3); background: var(--surface); color: var(--text3);
  border-radius: var(--r6); width: 34px; height: 34px; flex: none;
  font-size: var(--t-body); line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.icone:hover { background: var(--surface3); color: var(--text); }

/* Só o interior de cada vista desliza. */
.conteudo { flex: 1; min-height: 0; position: relative; overflow: hidden; }
.conteudo > section { position: absolute; inset: 0; display: flex; flex-direction: column; }

/* ---------------------------------------------------------------------------
   Rótulo de secção
   --------------------------------------------------------------------------- */
.rotulo {
  font-size: var(--m-label); font-weight: 500; line-height: 1;
  letter-spacing: var(--track-label); text-transform: uppercase;
  color: var(--text3);
}

/* ---------------------------------------------------------------------------
   Utilitários de texto. `.mono` já não muda de família — mudava a métrica a
   meio de uma linha. O que alinha uma coluna de números é o tabular-nums, e
   esse está no body.
   --------------------------------------------------------------------------- */
.mono  { font-variant-numeric: tabular-nums; }
.dim   { color: var(--text2); }
.mute  { color: var(--text3); }
.faint { color: var(--faint); }
.pos   { color: var(--green-text); }
.neg   { color: var(--neg); }
.gold  { color: var(--gold-text); }

/* ---------------------------------------------------------------------------
   Foco: obrigatório
   --------------------------------------------------------------------------- */
:where(a, button, input, select, [tabindex]):focus-visible {
  outline: none; box-shadow: var(--focus); border-radius: var(--r6);
}
.skip {
  position: absolute; left: var(--s5); top: var(--s2);
  transform: translateY(-200%);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line3); border-radius: var(--r8);
  padding: var(--s2) var(--s3); font-size: var(--t-small); z-index: 100;
}
.skip:focus { transform: translateY(0); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb {
  background: var(--line3); border-radius: var(--r6);
  border: 3px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-track { background: transparent; }

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