/* Rumo — design system. TODAS as cores/fontes/raios vivem neste :root
   (docs/DESIGN_RUMO.md §3); um passe de design mexe só aqui. */

/* Space Grotesk vendorizada (mesmo princípio do Leaflet: zero dependências de rede) */
@font-face{font-family:'Space Grotesk';font-weight:400;font-display:swap;
  src:url('/vendor/fonts/space-grotesk-400.woff2') format('woff2')}
@font-face{font-family:'Space Grotesk';font-weight:500;font-display:swap;
  src:url('/vendor/fonts/space-grotesk-500.woff2') format('woff2')}
@font-face{font-family:'Space Grotesk';font-weight:700;font-display:swap;
  src:url('/vendor/fonts/space-grotesk-700.woff2') format('woff2')}

:root{
  --fundo:#0B1120; --fundo-2:#131C2E; --fundo-3:#1B2740;
  --texto:#E8EDF5; --texto-2:#8296B5; --texto-3:#6E82A6;
  --acento:#2DD4A7; --acento-escuro:#04342C;
  --alerta:#F59E0B; --erro:#EF4444; --info:#60A5FA;
  --borda:#22304C; --raio:10px; --raio-cartao:12px;
  --fonte:'Space Grotesk',system-ui,-apple-system,'Segoe UI',sans-serif;
  --fonte-mono:ui-monospace,Consolas,monospace;
}
*{box-sizing:border-box;margin:0;padding:0}
body{background:var(--fundo);color:var(--texto);font-family:var(--fonte);min-height:100vh}
main{padding:1rem;max-width:1200px;margin:0 auto}

/* Assinatura Rumo: a "linha de rota" — traço descontínuo (como a polyline do mapa)
   que fecha cada título. Um só motivo, usado com contenção (h1 e login). */
h1{font-size:1.2rem;font-weight:500;margin:.2rem 0 1rem}
h1::after{content:"";display:block;width:44px;margin-top:.4rem;
  border-top:2px dashed var(--acento);opacity:.85}

/* Quality floor: foco visível ao teclado + respeitar reduced motion */
:focus-visible{outline:2px solid var(--acento);outline-offset:2px;border-radius:4px}
@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{transition:none !important;animation:none !important}
}

/* Motion de estado (registo product: comunica estado, nunca decora; 150–250 ms, ease-out) */
@keyframes pulso-anel{from{transform:scale(1);opacity:.55}to{transform:scale(2.4);opacity:0}}
@keyframes flash-valor{from{color:var(--acento)}}
.badge.pulso{position:relative;padding-left:1.15rem}
.badge.pulso::before{content:"";position:absolute;left:.45rem;top:50%;width:7px;height:7px;
  margin-top:-3.5px;border-radius:50%;background:currentColor}
.badge.pulso::after{content:"";position:absolute;left:.45rem;top:50%;width:7px;height:7px;
  margin-top:-3.5px;border-radius:50%;background:currentColor;
  animation:pulso-anel 1.6s cubic-bezier(.16,1,.3,1) infinite}
.valor.atualizado{animation:flash-valor .5s cubic-bezier(.16,1,.3,1)}
/* Posição atual no mapa ao vivo (substitui o pin estático do Leaflet) */
.marcador-vivo{position:relative}
.marcador-vivo::before{content:"";position:absolute;inset:0;border-radius:50%;
  background:var(--acento);border:2.5px solid var(--fundo);box-shadow:0 0 0 1px var(--acento)}
.marcador-vivo::after{content:"";position:absolute;inset:0;border-radius:50%;
  background:var(--acento);animation:pulso-anel 1.8s cubic-bezier(.16,1,.3,1) infinite}

/* Navegação de topo (Hub, desktop) */
.nav{display:flex;gap:.25rem;align-items:center;padding:.6rem 1rem;background:var(--fundo-2);border-bottom:1px solid var(--borda)}
.nav .marca{display:flex;align-items:center;gap:.45rem;font-weight:500;font-size:.95rem;margin-right:1rem;color:var(--texto)}
.nav .marca img{width:22px;height:22px}
.nav a{color:var(--texto-2);text-decoration:none;padding:.35rem .7rem;border-radius:var(--raio);transition:background 120ms,color 120ms}
.nav a.ativo,.nav a:hover{color:var(--texto);background:var(--fundo-3)}

/* Barra de separadores inferior (Hub, telemóvel) */
.tabbar{display:none;position:fixed;bottom:0;left:0;right:0;z-index:1000;
  background:var(--fundo-2);border-top:1px solid var(--borda);
  padding-bottom:env(safe-area-inset-bottom)}
.tabbar a{flex:1;display:flex;flex-direction:column;align-items:center;gap:2px;
  min-height:52px;padding:.45rem 0 .35rem;color:var(--texto-3);text-decoration:none;
  font-size:9px;transition:color 120ms}
.tabbar a svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.tabbar a.ativo{color:var(--acento)}

/* Mapa ao vivo */
.layout-mapa{display:grid;grid-template-columns:1fr 300px;gap:1rem;height:calc(100vh - 55px);padding:1rem;max-width:none;margin:0}
#mapa{border-radius:var(--raio);border:1px solid var(--borda);min-height:300px}
.painel{background:var(--fundo-2);border:1px solid var(--borda);border-radius:var(--raio-cartao);padding:1rem;overflow:auto}
.painel h2{font-size:.85rem;font-weight:500;color:var(--texto-2);margin-bottom:.8rem}

/* Cartões de métrica — lêem-se de relance (substituem dl/dd nos painéis) */
.metricas{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:.6rem}
.painel .metricas{grid-template-columns:1fr 1fr}
.metrica{background:var(--fundo-3);border-radius:var(--raio-cartao);padding:.7rem .8rem}
.painel .metrica{background:var(--fundo)}
.metrica .rotulo{color:var(--texto-3);font-size:11px}
.metrica .valor{font-size:22px;font-weight:500;font-family:var(--fonte-mono);margin-top:.15rem;overflow:hidden;text-overflow:ellipsis}
.metrica .valor .badge{font-family:var(--fonte)}

/* Badges de estado */
.badge{display:inline-block;padding:.15rem .6rem;border-radius:999px;font-size:.8rem;background:var(--fundo-3);color:var(--texto-2)}
.badge.ok{background:var(--acento);color:var(--acento-escuro)}
.badge.aviso{background:var(--alerta);color:#3A2A05}
.badge.mau{background:var(--erro);color:#fff}

/* Tabelas */
table{width:100%;border-collapse:collapse;background:var(--fundo-2);border-radius:var(--raio);overflow:hidden}
th,td{padding:.6rem .8rem;text-align:left;border-bottom:1px solid var(--borda)}
th{color:var(--texto-2);font-size:.78rem;font-weight:500}
tr:hover td{background:var(--fundo-3)}
a.botao{display:inline-block;background:var(--fundo-3);color:var(--info);padding:.35rem .7rem;border-radius:6px;text-decoration:none;font-size:.85rem;transition:filter 120ms}
a.botao:hover{filter:brightness(1.25)}

/* KPIs (detalhe da viagem) */
.kpis{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:.8rem;margin:1rem 0}
.kpi{background:var(--fundo-2);border:1px solid var(--borda);border-radius:var(--raio-cartao);padding:.9rem}
.kpi .rotulo{color:var(--texto-3);font-size:11px}
.kpi .valor{font-size:22px;font-weight:500;font-family:var(--fonte-mono);margin-top:.2rem}
.kpi .nota{color:var(--texto-3);font-size:.7rem}
.vazio{color:var(--texto-2);padding:2rem;text-align:center}

/* Página Sistema (vista de nós) */
.no{fill:var(--fundo-2);stroke:var(--borda);stroke-width:1.5}
.no.ok{stroke:var(--acento)} .no.aviso{stroke:var(--alerta)} .no.mau{stroke:var(--erro)}
.fio{stroke:var(--borda);stroke-width:2;fill:none}
.fio-seta{stroke:var(--borda);stroke-width:1.5;fill:none}
.svg-texto{fill:var(--texto);font-family:var(--fonte);font-size:13px}
.svg-sub{fill:var(--texto-2);font-size:11px;font-family:var(--fonte-mono)}
.rolavel{overflow-x:auto}
.rolavel svg{min-width:700px}
details.avancado{margin-top:1.5rem;border:1px solid var(--borda);border-radius:var(--raio-cartao);background:var(--fundo-2)}
details.avancado summary{cursor:pointer;padding:.8rem 1rem;color:var(--texto-2);font-size:.9rem}
details.avancado[open] summary{border-bottom:1px solid var(--borda)}
details.avancado .conteudo{padding:1rem}
.sparkline{stroke:var(--info);fill:none;stroke-width:1.5}
.sparkarea{fill:var(--info);opacity:.12}

/* Formulários e botões (alvo de toque ≥44px) */
.formulario{max-width:420px;background:var(--fundo-2);border:1px solid var(--borda);border-radius:var(--raio-cartao);padding:1.2rem}
main>.formulario{margin:0 auto}
.formulario label{display:block;color:var(--texto-2);font-size:.8rem;margin:.8rem 0 .3rem}
.formulario select,.formulario input{width:100%;min-height:44px;padding:.6rem;background:var(--fundo);border:1px solid var(--borda);border-radius:6px;color:var(--texto);font-family:var(--fonte-mono)}
.botao-grande{display:block;width:100%;min-height:48px;padding:.9rem;margin:.6rem 0 0;font-size:1.05rem;font-weight:500;border:none;border-radius:var(--raio);background:var(--acento);color:var(--acento-escuro);cursor:pointer;font-family:var(--fonte);transition:filter 120ms}
.botao-grande:hover{filter:brightness(1.08)}
.botao-grande:active{filter:brightness(.92);transform:translateY(1px)}
.botao-grande.perigo{background:var(--erro);color:#fff}
.botao-grande:disabled{background:var(--fundo-3);color:var(--texto-3);cursor:not-allowed;transform:none}
.aviso{color:var(--alerta);font-size:.9rem;margin-top:.8rem;min-height:1.2rem}
.aviso a{color:var(--info)}
.nota-rodape{color:var(--texto-3);font-size:.8rem;margin-top:1rem}
.nota-rodape a{color:var(--texto-2)}

/* Página de entrada (login) — o primeiro contacto com a marca */
.entrada{min-height:100vh;display:flex;flex-direction:column;justify-content:center;
  align-items:center;gap:1.5rem;padding:1rem;max-width:none}
.entrada-marca{display:flex;flex-direction:column;align-items:center;gap:.55rem;text-align:center;
  animation:entrada-suave .25s cubic-bezier(.16,1,.3,1)}
@keyframes entrada-suave{from{opacity:0;transform:translateY(6px)}}
.entrada-marca img{width:54px;height:54px}
.entrada-marca .nome{font-size:1.55rem;font-weight:700;letter-spacing:-.01em}
.entrada-marca .tagline{color:var(--texto-2);font-size:.92rem}
.entrada-marca .rota{width:130px;border-top:2px dashed var(--acento);margin-top:.5rem;opacity:.85}
.entrada .formulario{width:100%;max-width:360px}

/* Rumo Drive (telemóvel, página própria — sem nav do Hub) */
.drive{max-width:440px;margin:0 auto;padding:1rem;display:flex;flex-direction:column;gap:.8rem}
.drive-header{display:flex;flex-wrap:wrap;align-items:center;gap:.5rem;padding:.4rem 0 .2rem}
.drive-header::after{content:"";flex-basis:100%;width:44px;max-width:44px;
  border-top:2px dashed var(--acento);margin-top:.35rem;opacity:.85}
.drive-header img{width:26px;height:26px}
.drive-header .nome{font-size:1.05rem;font-weight:500}
.drive-header .nome span{color:var(--acento)}
.drive .formulario{max-width:none}
.drive .botao-grande{min-height:56px;font-size:1.15rem}

/* Telemóvel (<800px): tabbar em vez do nav; tabelas viram cartões */
@media (max-width:800px){
  .nav{display:none}
  .tabbar{display:flex}
  main{padding:.8rem .8rem 84px}
  .layout-mapa{grid-template-columns:1fr;height:auto;padding:.8rem .8rem 84px}
  #mapa{height:56vh}
  table.responsiva{background:none;border-radius:0}
  table.responsiva thead{display:none}
  table.responsiva tr{display:block;background:var(--fundo-2);border:1px solid var(--borda);border-radius:var(--raio-cartao);margin-bottom:.6rem;padding:.3rem 0}
  table.responsiva td{display:flex;justify-content:space-between;align-items:center;gap:.8rem;border:none;padding:.35rem .9rem;text-align:right}
  table.responsiva td::before{content:attr(data-label);color:var(--texto-3);font-size:.78rem;text-align:left}
  table.responsiva td:not([data-label])::before{content:none}
  table.responsiva tr:hover td{background:none}
}
