/* ============================================================================
   Sistema visual — Plataforma de Contratos, Grupo Castel

   É o mesmo sistema do Signal (signal-os/frontend/src/control/signal.css):
   papel quente, uma barra lateral escura que flutua como cartão, folhas
   brancas de canto largo separadas por tom e sombra suave — não por fio —,
   cobre como único acento, e a fonte do sistema em tudo. Rótulos em
   maiúsculas pequenas no sans, nunca em monoespaçado: o mono fica reservado
   ao número, que é a única coisa que precisa de alinhar em coluna.

   A versão anterior (serifa no título, mono maiúsculo nos rótulos e botões,
   cartão com fio de 1px) era a assinatura que a cliente leu como "feito por
   IA". Este ficheiro troca a pele; as classes são as mesmas.
   ========================================================================= */

:root {
  --paper:      #f6f4ef;
  --paper-2:    #eeebe5;
  --paper-3:    #f2ece3;
  --surface:    #fffefb;
  --surface-2:  #f4f0e9;
  --surface-3:  #eae6dd;
  --line:       #e1dad0;
  --line-soft:  #ede7dd;
  --ink:        #282825;
  --ink-2:      #554d45;
  --ink-3:      #77756e;
  --ink-4:      #8b7b6c;
  --ink-5:      #aaa49b;

  --accent:     #a75d3f;   /* cobre: o CTA, a linha focal, a selecção */
  --accent-2:   #b67956;
  --accent-bg:  #efe4d8;
  --danger:     #b94b40;
  --danger-bg:  #f5e3df;
  --danger-ink: #994a3d;
  --warn:       #bb861f;
  --warn-bg:    #eee3c9;
  --warn-ink:   #846b31;
  --ok:         #537466;
  --ok-bg:      #dde9df;
  --ok-ink:     #466652;
  --info:       #4d646c;
  --info-bg:    #e2e8ea;
  --quiet-bg:   #e9e7df;
  --quiet-ink:  #6b695d;

  --r:      22px;
  --r-md:   20px;
  --r-sm:   12px;
  --r-pill: 20px;

  --shadow: 0 3px 18px #40321803;
  --shadow-up: 0 8px 24px #3c2e2010;

  --sans:  -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  --serif: var(--sans);
  --mono:  ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  letter-spacing: -0.015em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------------------------------------------------------------- tipografia */
.display {
  font-family: var(--sans);
  font-weight: 500;
  letter-spacing: -0.05em;
  line-height: 1.16;
  font-size: clamp(28px, 3vw, 43px);
  margin: 0;
}
.display em { font-style: normal; color: var(--ink-3); }

h2, h3 { font-family: var(--sans); font-weight: 500; margin: 0; }
h2 { font-size: 24px; line-height: 1.25; letter-spacing: -0.035em; }
h3 { font-size: 17px; line-height: 1.35; font-weight: 550; letter-spacing: -0.02em; }

/* O rótulo em maiúsculas pequenas é o elemento de navegação do sistema:
   diz onde se está sem precisar de caixa à volta. Sans, não mono. */
.label {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 550;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink-4);
}
.label-ink { color: var(--ink-2); }

.num {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.muted { color: var(--ink-3); }
.dim   { color: var(--ink-2); }
.small { font-size: 12.5px; line-height: 1.55; }
.tiny  { font-size: 11.5px; line-height: 1.5; }

hr, .rule { border: 0; border-top: 1px solid var(--line); margin: 0; }

a { color: inherit; }

/* -------------------------------------------------------------------- cartões */
.card {
  background: var(--surface);
  border: 0;
  border-radius: var(--r);
  padding: 25px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-flush { padding: 0; overflow: hidden; }
.card-quiet { background: var(--surface-2); box-shadow: none; }
.card-hd {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 14px; margin-bottom: 15px;
}

/* mostrador numérico — o bloco de indicador do Signal: fundo de areia, sem fio */
.stat { display: flex; flex-direction: column; gap: 8px; }
.card.stat { background: var(--surface-3); box-shadow: none; border-radius: var(--r-md); padding: 22px 23px; }
.stat-v {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: clamp(24px, 2.6vw, 32px);
  font-weight: 500;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--ink);
  margin-top: 4px;
}
.stat-u { font-size: 12px; color: var(--ink-3); font-weight: 400; letter-spacing: 0; font-family: var(--sans); }
.stat-n { font-size: 12px; color: var(--ink-2); line-height: 1.55; }
.stat .bar { margin: 6px 0 2px; }

/* pastilhas: mansas, sem caixa alta, sem fio */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--sans); font-size: 10px; font-weight: 400;
  letter-spacing: 0; text-transform: none;
  padding: 4px 9px; border-radius: var(--r-pill);
  border: 0; white-space: nowrap;
  background: var(--quiet-bg); color: var(--quiet-ink);
}
.pill-danger { background: var(--danger-bg); color: var(--danger-ink); }
.pill-warn   { background: var(--warn-bg);   color: var(--warn-ink); }
.pill-ok     { background: var(--ok-bg);     color: var(--ok-ink); }
.pill-info   { background: var(--info-bg);   color: var(--info); }
.pill-accent { background: var(--accent-bg); color: #946445; }
.pill-quiet  { background: var(--quiet-bg);  color: var(--quiet-ink); }

/* botões: raio 12, fundo de areia, cobre só no sólido */
button, .btn {
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  letter-spacing: -0.015em; text-transform: none;
  padding: 10px 15px; border-radius: var(--r-sm);
  border: 0; background: var(--paper-2); color: #34332f;
  cursor: pointer; transition: background .15s ease, color .15s ease;
  line-height: 1.3;
}
button:hover, .btn:hover { background: #e6dfd5; color: var(--ink); }
button:disabled { opacity: .45; cursor: not-allowed; }
.btn-solid { background: var(--accent); color: #fff; box-shadow: 0 3px 7px #98472512; }
.btn-solid:hover { background: #934d32; color: #fff; }
.btn-sm { padding: 7px 11px; font-size: 12px; }
/* chip pequeno seleccionado é tinta escura, como os filtros do Signal —
   o cobre fica reservado ao CTA de página */
.btn-sm.btn-solid { background: #3a342f; color: #fff; box-shadow: none; }
.btn-sm.btn-solid:hover { background: #262720; }

input, textarea, select {
  font-family: var(--sans); font-size: 14px;
  background: #fffdf7; color: var(--ink);
  border: 1px solid #ddd4c6; border-radius: 10px;
  padding: 10px 12px; width: 100%;
  letter-spacing: -0.015em;
}
input:focus, textarea:focus, select:focus {
  outline: none; border-color: #b56444;
  box-shadow: 0 0 0 3px #b5644422;
}

/* --------------------------------------------------------------------- tabelas */
table { width: 100%; border-collapse: collapse; font-size: 12px; }
thead th {
  font-family: var(--sans); font-size: 10px; font-weight: 400;
  letter-spacing: 0; text-transform: none; color: #91887d;
  text-align: left; padding: 10px 12px 14px;
  border-bottom: 0; white-space: nowrap;
}
tbody td { padding: 12px; border-bottom: 0; vertical-align: middle; }
tbody tr:nth-child(even) td { background: #f8f6f1; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.hoverable:hover td { background: #efe4d8; cursor: pointer; }
tbody td:first-child { border-radius: 12px 0 0 12px; }
tbody td:last-child { border-radius: 0 12px 12px 0; }
td.r, th.r { text-align: right; }
td.n { font-family: var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; font-size: 11.5px; }

.scroll-x { overflow-x: auto; max-width: 100%; scrollbar-width: thin; }
.scroll-x table { min-width: 560px; }

/* --------------------------------------------------------------------- grelhas */
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
.grid > * { min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }

/* ------------------------------------------------------- barra de proporção */
.bar { height: 8px; border-radius: 10px; background: #e4dbce; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 10px; background: #986046; }

/* ------------------------------------------------------------------- gráficos */
.chart { width: 100%; display: block; overflow: visible; }
.chart .axis { stroke: #d4cabd; stroke-width: 1; }
.chart .grid-l { stroke: #e7e1d9; stroke-width: 1; stroke-dasharray: 3 6; }
.chart .band { fill: var(--paper-3); }
.chart .line { fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
.chart .line-accent { fill: none; stroke: #ae5b3b; stroke-width: 1.8; stroke-dasharray: 3.5 3.5; stroke-linecap: round; }
.chart .line-danger { fill: none; stroke: var(--danger); stroke-width: 1.4; }
.chart .dot { fill: var(--surface); stroke: var(--ink); stroke-width: 1.6; }
.chart .dot-accent { fill: var(--surface); stroke: #ae5b3b; stroke-width: 1.6; }
.chart .tick {
  font-family: var(--sans); font-size: 9px; letter-spacing: 0;
  fill: #89847d; text-transform: none;
}
.chart .val {
  font-family: var(--mono); font-size: 9.5px; font-weight: 500;
  fill: var(--ink-2); letter-spacing: -0.02em;
}

/* ------------------------------------------------------------------ estrutura */
.shell { display: flex; min-height: 100vh; background: var(--paper); }

/* A barra lateral é um cartão escuro que flutua no papel — não uma coluna
   colada à borda. Os tokens de tinta são redefinidos aqui para que o texto
   escrito inline com var(--ink-4) fique legível sobre o escuro. */
.side {
  --ink: #faf8f2; --ink-2: #e9e7e0; --ink-3: #bcbdb2; --ink-4: #aaa99f; --ink-5: #949688;
  --line: #3d4036; --line-soft: #3d4036; --paper-2: #3d4036;
  width: 224px; flex-shrink: 0;
  background: #272923; color: #e9e7e0;
  margin: 16px 0 16px 16px;
  border: 0; border-radius: 26px;
  padding: 32px 18px 22px;
  display: flex; flex-direction: column; gap: 24px;
  position: sticky; top: 16px; height: calc(100vh - 32px);
  overflow-y: auto; scrollbar-width: thin;
}
.side > div:first-child { padding: 0 10px; }
.side .label { color: #aaa99f; }
.side-grp { display: flex; flex-direction: column; gap: 5px; }
.side-grp > .label { padding: 0 10px 8px; }
.nav {
  display: block; width: 100%; text-align: left;
  border: 0; background: transparent; border-radius: 13px;
  padding: 12px 15px; cursor: pointer;
  font-family: var(--sans); font-size: 13.5px; letter-spacing: -0.015em;
  text-transform: none; color: #bcbdb2; line-height: 1.35; font-weight: 400;
}
.nav small { display: block; font-size: 11.5px; color: #8e8f84; margin-top: 2px; }
.nav:hover { background: #3d4036; color: #fff; }
.nav:hover small { color: #c9cabe; }
.nav.on { background: #f2eee6; color: #303129; box-shadow: 0 3px 12px #0002; font-weight: 500; }
.nav.on small { color: #6b6960; }
.nav.on:hover { background: #f2eee6; color: #303129; }
.nav.off { opacity: .38; cursor: not-allowed; }
.nav.off:hover { background: transparent; color: #bcbdb2; }
.side button:not(.nav) { background: transparent; color: #bfc1b4; padding: 5px 0; font-size: 11.5px; text-align: left; }
.side button:not(.nav):hover { background: transparent; color: #fff; }

.main { flex: 1; min-width: 0; padding: 24px clamp(22px, 3vw, 56px) 80px; max-width: 1850px; margin: 0 auto; }
.page-hd { margin: 8px 0 26px; }
.page-hd .label { margin-bottom: 8px; display: inline-block; }

@media (max-width: 900px) {
  .shell { display: block; }
  .side { position: static; width: auto; height: auto; margin: 10px; border-radius: 20px; padding: 18px; gap: 14px; }
  .side > div:first-child { padding: 0 4px; }
  .main { padding: 12px 18px 60px; }
}

/* --------------------------------------------------------------------- ecrãs */
.gate {
  min-height: 100vh; display: grid; place-items: center; padding: 26px;
  background: var(--paper);
}
.gate-box { width: 100%; max-width: 440px; }

/* linha do tempo */
.tl { position: relative; padding-left: 26px; }
.tl::before {
  content: ''; position: absolute; left: 5px; top: 6px; bottom: 6px;
  width: 1px; background: var(--line);
}
.tl-i { position: relative; padding: 0 0 20px; }
.tl-i:last-child { padding-bottom: 0; }
.tl-i::before {
  content: ''; position: absolute; left: -24px; top: 6px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--surface); border: 1.6px solid var(--ink-5);
}
.tl-i.on::before { border-color: var(--accent); background: var(--accent); }
.tl-i.risk::before { border-color: var(--danger); background: var(--danger); }
.tl-i.fut::before { border-style: dashed; border-color: var(--ink-5); background: var(--paper); }

/* corpo de achado — markdown simples */
.body p { margin: 0 0 10px; }
.body p:last-child { margin-bottom: 0; }
.body strong { font-weight: 600; color: var(--ink); }
.body em { font-style: italic; color: var(--ink-2); }
.body code {
  font-family: var(--mono); font-size: 12px;
  background: var(--paper-2); padding: 1px 5px; border-radius: 4px;
}

details > summary { cursor: pointer; list-style: none; }
details > summary::-webkit-details-marker { display: none; }

.spin { display: inline-block; width: 13px; height: 13px; border: 1.5px solid var(--line);
        border-top-color: var(--accent); border-radius: 50%; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }

::selection { background: var(--accent-bg); color: var(--ink); }
:focus-visible { outline: 3px solid #b56444; outline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
