/* Pulso · SGT — folha única de estilos.
   Instrumento clínico monocromático: cor apenas onde é sinal (ponto morto,
   entregue, aéreo ao vivo, erro, risco térmico). Temas claro/escuro via
   tokens light-dark() + data-tema no <html>. */

/* Fontes vendorizadas (OFL) — sem CDN. */
@font-face {
  font-family: "Bricolage Grotesque";
  src: url("./fonts/bricolage-var.woff2") format("woff2");
  font-weight: 200 800; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/plex-mono-400.woff2") format("woff2");
  font-weight: 400; font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("./fonts/plex-mono-600.woff2") format("woff2");
  font-weight: 600; font-display: swap;
}

:root {
  /* O escuro é o tema canônico: a Câmara Fria. O claro continua servido,
     mas é a alternativa, não o padrão. Ver DESIGN.md na raiz. */
  color-scheme: dark light;

  --font-display: "Bricolage Grotesque", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* ---- escala tipográfica: 8 degraus, razão 1.25, base 14 ----
     Abaixo de 1.25 a hierarquia lê como ruído, não como hierarquia. */
  --t1: 11px;  --t2: 14px;  --t3: 18px;  --t4: 22px;
  --t5: 27px;  --t6: 34px;  --t7: 43px;  --t8: 53px;
  /* mesma progressão, dois degraus além: só o modo TV alcança */
  --t9: 66px;  --t10: 83px;

  /* ---- escala de espaço ---- */
  --e1: 4px;   --e2: 8px;   --e3: 12px;  --e4: 16px;
  --e5: 24px;  --e6: 32px;  --e7: 48px;

  /* ---- escala de raio ---- */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px; --r-full: 999px;

  /* ---- movimento: ease-out exponencial, sem bounce ---- */
  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-tatil: cubic-bezier(.22, 1, .36, 1);
  --dur-estado: .15s; --dur-camada: .28s; --dur-entrada: .55s;

  /* ---- a câmara: 4 degraus de grafite violeta (matiz 300) ----
     O matiz 300 é a maior distância possível de todos os sinais em uso
     (27 erro, 50 ponto morto, 88 FR24, 152 frota, 155 conforme, 245 aéreo):
     nenhum sinal compete com a própria superfície. Em croma 0.010 não lê
     como roxo, lê como grafite frio.
     No escuro nada desce do degrau 16%, e a superfície de trabalho parte de
     21%: numa TV sob luz de escritório o reflexo levanta o piso de preto, e
     partir mais alto mantém a razão de contraste de pé. */
  --band:   light-dark(oklch(21% 0.012 300), oklch(16% 0.010 300));
  --bg:     light-dark(oklch(97.4% 0.006 300), oklch(21% 0.010 300));
  --panel:  light-dark(oklch(99.3% 0.003 300), oklch(25% 0.012 300));
  --chip:   light-dark(oklch(94.5% 0.006 300), oklch(29% 0.013 300));
  --critica: light-dark(oklch(91% 0.010 300), oklch(33% 0.014 300));

  --ink:   light-dark(oklch(25% 0.022 300), oklch(95% 0.006 300));
  --muted: light-dark(oklch(51% 0.020 300), oklch(72% 0.010 300));
  --line:  light-dark(oklch(91% 0.012 300), oklch(34% 0.014 300));
  --line-strong: light-dark(oklch(84% 0.018 300), oklch(44% 0.016 300));

  --band-ink: oklch(95% 0.006 300);
  --band-muted: oklch(66% 0.012 300);
  --pulse: oklch(87% 0.008 300);

  /* "brand" monocromático: o acento é a própria tinta, não uma cor */
  --brand: light-dark(oklch(28% 0.015 300), oklch(95% 0.006 300));
  --brand-ink: light-dark(oklch(97% 0.004 300), oklch(21% 0.010 300));

  /* ---- elevação = severidade. Repouso é chapado; sombra é resposta a
     estado, e o estado que mais importa neste produto é gravidade. ---- */
  --sombra-elevada: 0 2px 8px light-dark(oklch(25% 0.02 300 / .10), oklch(10% 0.010 300 / .5));
  --sombra-critica: 0 8px 28px light-dark(oklch(25% 0.02 300 / .14), oklch(10% 0.010 300 / .55));
  --shadow: 0 16px 48px light-dark(oklch(25% 0.02 300 / .16), oklch(8% 0.010 300 / .6));

  --ok: light-dark(oklch(52% 0.115 155), oklch(72% 0.12 155));
  --ok-bg: light-dark(oklch(94.5% 0.04 155), oklch(30% 0.05 158));
  --air: light-dark(oklch(52% 0.1 245), oklch(74% 0.1 245));
  --air-bg: light-dark(oklch(94.5% 0.03 245), oklch(30% 0.05 248));
  /* amarelo-FR24: só para a aeronave no mapa (cor de marca, reconhecível) */
  --fr24: light-dark(oklch(80% 0.155 85), oklch(84% 0.16 88));
  --fr24-borda: oklch(38% 0.06 75);
  --fr24-tinta: light-dark(oklch(50% 0.11 78), oklch(84% 0.145 86)); /* legível como texto */
  /* verde-frota: caminhões da Autotrac no mapa (em movimento) */
  --atic: light-dark(oklch(60% 0.13 152), oklch(74% 0.14 152));
  --atic-borda: oklch(32% 0.06 152);
  /* estado intermediário é o cotidiano: neutro, cor só onde há sinal */
  --warn: light-dark(oklch(40% 0.015 300), oklch(82% 0.012 300));
  --warn-bg: light-dark(oklch(93.5% 0.006 300), oklch(29% 0.013 300));
  --wait: light-dark(oklch(38% 0.015 300), oklch(82% 0.012 300));
  --wait-bg: light-dark(oklch(93.5% 0.006 300), oklch(29% 0.013 300));
  --idle: light-dark(oklch(55% 0.020 300), oklch(78% 0.012 300));
  --idle-bg: light-dark(oklch(93.5% 0.008 300), oklch(29% 0.013 300));
  --err: light-dark(oklch(52% 0.16 27), oklch(72% 0.13 27));
  --err-bg: light-dark(oklch(94.5% 0.03 27), oklch(30% 0.06 27));
  --dead: light-dark(oklch(58% 0.155 45), oklch(74% 0.13 50));
  --dead-bg: light-dark(oklch(95% 0.035 55), oklch(30% 0.06 50));
}
:root[data-tema="claro"] { color-scheme: light; }
:root[data-tema="escuro"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: var(--t2)/1.5 var(--font-body);
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: var(--r-sm); }

/* ---- faixa de identidade ---- */
header.top {
  display: flex; align-items: center; gap: 16px;
  padding: 15px 24px 14px;
  background: var(--band); color: var(--band-ink);
}
.ecg { width: 92px; height: 26px; color: var(--pulse); flex: none; }
.ecg .traco { opacity: .28; }
.ecg .onda { stroke-dasharray: 26 74; animation: sweep 3.4s linear infinite; }
@keyframes sweep { from { stroke-dashoffset: 100; } to { stroke-dashoffset: 0; } }
h1 {
  margin: 0; font-family: var(--font-display);
  font-size: var(--t4); font-weight: 640; letter-spacing: -.015em;
}
h1 small {
  display: block; font-family: var(--font-body); font-size: var(--t1);
  font-weight: 500; color: var(--band-muted); letter-spacing: .015em; margin-top: 1px;
}
.grow { flex: 1; }
.updated { color: var(--band-muted); font-family: var(--font-mono); font-size: var(--t1); }

/* ---- pesquisa global (no meio da faixa, estilo portal) ---- */
.gbusca { position: relative; flex: 0 1 460px; min-width: 0; }
.gbusca .lupa {
  position: absolute; left: 11px; top: 50%; translate: 0 -50%;
  width: 14px; height: 14px; color: var(--band-muted); pointer-events: none;
}
#gbuscaInput {
  width: 100%; font: inherit; font-size: var(--t2); color: var(--band-ink);
  background: oklch(100% 0 0 / .07); border: 1px solid oklch(100% 0 0 / .14);
  border-radius: var(--r-md); padding: 7px 46px 7px 33px; outline: none;
  transition: background .15s, border-color .15s;
}
#gbuscaInput::placeholder { color: var(--band-muted); }
#gbuscaInput::-webkit-search-cancel-button { display: none; }
#gbuscaInput:hover { background: oklch(100% 0 0 / .1); }
#gbuscaInput:focus { background: oklch(100% 0 0 / .13); border-color: oklch(100% 0 0 / .32); }
#gbuscaKbd {
  position: absolute; right: 9px; top: 50%; translate: 0 -50%;
  font: 600 var(--t1) var(--font-mono); color: var(--band-muted);
  border: 1px solid oklch(100% 0 0 / .18); border-radius: var(--r-sm);
  padding: 1px 5px; pointer-events: none;
}
.gbusca:focus-within #gbuscaKbd { display: none; }
.gbusca-drop {
  position: absolute; top: calc(100% + 9px); left: 50%; translate: -50% 0;
  width: min(560px, 92vw); max-height: min(480px, 70vh); overflow: auto;
  background: var(--panel); color: var(--ink); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); padding: 6px; z-index: 1200;
}
.gbusca-sec {
  font-size: var(--t1); font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); padding: 8px 10px 4px;
}
.gbusca-sec + .gbusca-sec { border-top: 1px solid var(--line); }
.gbusca-item {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 10px; border-radius: var(--r-sm); cursor: pointer;
}
.gbusca-item.on, .gbusca-item:hover { background: var(--chip); }
.gbusca-item .t { font-family: var(--font-mono); font-weight: 600; font-size: var(--t2); white-space: nowrap; }
.gbusca-item .s {
  flex: 1; min-width: 0; color: var(--muted); font-size: var(--t2);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.gbusca-vazio { padding: 14px 12px; color: var(--muted); font-size: var(--t2); }
html.tv .gbusca { display: none !important; }
@media (max-width: 900px) { .gbusca { display: none; } }

/* ---- abas ---- */
.tabs {
  display: flex; align-items: center; gap: 2px; padding: 0 24px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 1001; /* acima dos panes do Leaflet */
}
.tab {
  font: inherit; font-weight: 600; color: var(--muted); background: none;
  border: 0; padding: 13px 14px 11px; cursor: pointer; position: relative;
  white-space: nowrap;
  transition: color .18s cubic-bezier(.22,1,.36,1);
}
.tab::after {
  content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px;
  height: 2px; background: var(--brand); border-radius: 2px 2px 0 0;
  transform: scaleX(0); transform-origin: center;
  transition: transform .28s cubic-bezier(.22,1,.36,1);
}
.tab:hover { color: var(--ink); }
.tab.active { color: var(--brand); }
.tab.active::after { transform: scaleX(1); }

.view { padding: 22px 24px 56px; max-width: 1440px; margin: 0 auto; }

/* ---- barra do dia ---- */
.dia-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.dia-bar label { color: var(--muted); font-weight: 600; }
.dia-bar input[type=date] {
  font: 600 var(--t2) var(--font-mono); color: var(--ink); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 8px 11px;
}
.badge-demo {
  font-size: var(--t1); font-weight: 700; color: var(--brand); background: var(--chip);
  border: 1px solid var(--line); padding: 3px 10px; border-radius: var(--r-full);
  text-transform: uppercase; letter-spacing: .06em;
}
.btnnav {
  font: inherit; border: 1px solid var(--line-strong); background: var(--panel);
  color: var(--ink); border-radius: var(--r-md); width: 34px; height: 34px; cursor: pointer;
  font-size: var(--t2); transition: border-color .15s, transform .15s cubic-bezier(.22,1,.36,1);
}
.btnnav:hover { border-color: var(--brand); }
.btnnav:active { transform: scale(.94); }

/* ---- strip de indicadores ---- */
.kpis {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  margin: 0 0 22px; padding: 4px 0 14px; border-bottom: 1px solid var(--line);
}
.kpi { padding: 4px 20px 0; animation: rise .55s cubic-bezier(.16,1,.3,1) both; animation-delay: calc(var(--i, 0) * 70ms); }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi .n {
  font-family: var(--font-display); font-size: var(--t6); font-weight: 560;
  letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.kpi .l { color: var(--muted); font-size: var(--t1); text-transform: uppercase; letter-spacing: .09em; margin-top: 3px; font-weight: 600; }
.kpi.brand .n { color: var(--brand); }
.kpi.dead .n { color: var(--dead); }
@keyframes rise { from { opacity: 0; transform: translateY(7px); } to { opacity: 1; transform: none; } }

/* ---- cartões ---- */
.cards2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; margin-bottom: 22px; }
/* repouso é chapado: sombra só como resposta a estado (ver DESIGN.md) */
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--e4) var(--e5);
  transition: background var(--dur-camada) var(--ease), box-shadow var(--dur-camada) var(--ease);
}
.card h3 {
  margin: 0 0 14px; font-size: var(--t1); text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); font-weight: 700;
}
.prog-track { height: 10px; border-radius: var(--r-full); background: var(--idle-bg); overflow: hidden; }
.prog-fill { background: var(--ok); height: 100%; border-radius: var(--r-full); transition: width .6s cubic-bezier(.16,1,.3,1); }
.prog-legend { display: flex; gap: 26px; margin-top: 14px; font-size: var(--t2); }
.prog-legend b { font-family: var(--font-display); font-size: var(--t4); font-weight: 560; display: block; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.dot-ok { color: var(--ok); } .dot-wait { color: var(--wait); }

.dead-row { display: flex; align-items: baseline; gap: 12px; }
.dead-row .big {
  font-family: var(--font-display); font-size: var(--t7); font-weight: 600;
  color: var(--dead); letter-spacing: -.02em; line-height: 1;
  font-variant-numeric: tabular-nums; position: relative;
}
/* mistura em srgb: em oklch o matiz interpola pelo caminho errado e esverdeia */
.card.alerta {
  border-color: color-mix(in srgb, var(--dead) 55%, var(--line));
  background: color-mix(in srgb, var(--dead) 10%, var(--critica));
  box-shadow: var(--sombra-critica);
}
.card.alerta .big::after {
  content: ""; position: absolute; inset: -10px -14px; border-radius: var(--r-full);
  border: 2px solid var(--dead); opacity: 0;
  animation: pulsar 2.4s cubic-bezier(.16,1,.3,1) infinite;
}
@keyframes pulsar { 0% { opacity: .5; transform: scale(.7); } 70%, 100% { opacity: 0; transform: scale(1.15); } }
.dead-note { color: var(--muted); font-size: var(--t2); margin-top: 12px; padding-top: 12px; border-top: 1px dashed var(--line); }
.lock { display: inline-flex; align-items: center; gap: 7px; margin-top: 10px; font-size: var(--t2); color: var(--muted); }
.lock svg { width: 12px; height: 12px; flex: none; }

/* ---- filtros ---- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.filters input, .filters select {
  font: inherit; color: var(--ink); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 8px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.filters input:focus, .filters select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in oklch, var(--brand) 18%, transparent); }
#busca, #diaBusca { min-width: 240px; flex: 1; max-width: 420px; }
.btn {
  font: inherit; font-weight: 650; cursor: pointer; border: 1px solid var(--brand);
  background: var(--brand); color: var(--brand-ink); border-radius: var(--r-md); padding: 8px 16px;
  transition: transform .15s cubic-bezier(.22,1,.36,1), box-shadow .2s;
}
.btn:hover:not([disabled]) { box-shadow: 0 4px 14px color-mix(in oklch, var(--brand) 35%, transparent); }
.btn:active:not([disabled]) { transform: scale(.97); }
.btn[disabled] { opacity: .45; cursor: default; }
.count { color: var(--muted); font-size: var(--t2); margin-left: auto; font-variant-numeric: tabular-nums; }

/* ---- tabelas ---- */
table {
  width: 100%; border-collapse: collapse; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden;
}
thead th {
  text-align: left; font-size: var(--t1); text-transform: uppercase; letter-spacing: .07em;
  color: var(--muted); padding: 12px; border-bottom: 1px solid var(--line); font-weight: 700;
}
tbody td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; transition: background .12s, box-shadow .12s; }
tbody tr.click:hover { background: var(--chip); box-shadow: inset 2.5px 0 0 var(--brand); }
.awb { font-family: var(--font-mono); font-weight: 600; font-size: var(--t2); }
.mono { font-family: var(--font-mono); font-size: var(--t2); }
.sub { color: var(--muted); font-size: var(--t2); }
.arrow { color: var(--muted); margin: 0 5px; }
.sentinela td, .sentinela { text-align: center; color: var(--muted); font-size: var(--t2); padding: 10px; }

/* ---- logos de companhia: cinza em repouso, cor da marca no hover ---- */
.logo-box {
  display: inline-flex; align-items: center; padding: 3px 8px; border-radius: var(--r-sm);
  /* plaqueta clara só no tema escuro (logos têm tinta escura) */
  background: light-dark(oklch(100% 0 0 / 0), oklch(96.5% 0.004 300));
}
.logo-cia { display: block; height: 12px; width: auto; filter: grayscale(1) opacity(.72); transition: filter .3s ease; }
.logo-cia.gol { height: 17px; }
.logo-cia.azul { height: 13px; }
tr:hover .logo-cia, .mrow:hover .logo-cia { filter: none; }
#dSub .logo-cia { filter: none; height: 14px; } /* no drawer, a remessa em foco merece a marca */
#dSub .logo-cia.gol { height: 20px; }

/* ---- trilho de rota: origem ●──✈──● destino ---- */
.rota { display: inline-flex; align-items: center; gap: 7px; }
.rota .uf { font-weight: 600; }
.trilho { width: 64px; height: 16px; overflow: visible; flex: none; }
.trilho .pino { fill: var(--line-strong); }
.trilho .via { stroke: var(--line-strong); stroke-width: 1.5; stroke-dasharray: 4 4; }
.trilho .aviao { fill: var(--muted); transform: translate(26px, 8px); transition: transform .5s cubic-bezier(.3,.7,.3,1), fill .3s; }
tbody tr.click:hover .trilho .aviao { transform: translate(42px, 8px); fill: var(--ink); }
tbody tr.click:hover .trilho .via { animation: fluir-via .45s linear infinite; }
@keyframes fluir-via { to { stroke-dashoffset: -8; } }
.foot { color: var(--muted); font-size: var(--t2); padding: 14px 4px; }

/* ---- chips ---- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 2.5px 9px;
  border-radius: var(--r-full); font-size: var(--t1); font-weight: 650;
  background: var(--idle-bg); color: var(--idle); white-space: nowrap;
}
/* companhia é identificação, não estado: chip neutro de contorno */
.chip.gol, .chip.latam, .chip.azul {
  background: transparent; border: 1px solid var(--line-strong); color: var(--muted);
  font-family: var(--font-mono); font-size: var(--t1); letter-spacing: .04em;
}
.st { background: var(--idle-bg); color: var(--idle); }
.st.ok { background: var(--ok-bg); color: var(--ok); }
.st.air { background: var(--air-bg); color: var(--air); }
.st.warn { background: var(--warn-bg); color: var(--warn); }
.st.wait { background: var(--wait-bg); color: var(--wait); }
.st.err { background: var(--err-bg); color: var(--err); }
.st.load { background: var(--air-bg); color: var(--air); }
.st.dead { background: var(--dead-bg); color: var(--dead); }
/* Severidade precisa de forma, não só de cor. Em escala de cinza "sem logger"
   ficava idêntico ao número do logger ao lado, que é dado e não problema.
   Só o que é grave recebe marca: se tudo fosse marcado, a marca não separaria
   nada. Medida em em, então acompanha o corpo do chip e cresce sozinha na TV.
   Triângulo é erro; quadrado é ponto cego, ausência de sinal. */
.st.err::before, .st.dead::before {
  content: ""; flex: none; width: .62em; height: .62em; background: currentColor;
}
.st.err::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.st.dead::before { border-radius: 1px; }
/* carga a bordo de um avião no ar agora (FR24): ponto que pulsa */
.st.vivo .ping {
  width: 7px; height: 7px; border-radius: 50%; background: currentColor;
  animation: ping 1.8s cubic-bezier(0, 0, .2, 1) infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, currentColor 45%, transparent); }
  70%, 100% { box-shadow: 0 0 0 6px transparent; }
}
@media (prefers-reduced-motion: reduce) { .st.vivo .ping { animation: none; } }
.spin { width: 11px; height: 11px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; display: inline-block; animation: sp .7s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.dim { color: var(--muted); }

/* ---- drawer ---- */
.scrim { position: fixed; inset: 0; background: oklch(12% 0.014 300 / .55); opacity: 0; pointer-events: none; transition: opacity .2s; z-index: 1040; }
.scrim.on { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; height: 100%; width: min(560px, 94vw);
  background: var(--panel); border-left: 1px solid var(--line); box-shadow: var(--shadow);
  transform: translateX(100%); transition: transform .32s cubic-bezier(.16,1,.3,1);
  z-index: 1041; display: flex; flex-direction: column;
}
.drawer.on { transform: none; }
.drawer header { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.drawer header .x {
  margin-left: auto; cursor: pointer; border: 0; background: var(--chip); color: var(--ink);
  width: 30px; height: 30px; border-radius: var(--r-md); font-size: var(--t2); transition: transform .15s;
}
.drawer header .x:active { transform: scale(.92); }
.drawer .body { overflow: auto; padding: 20px 22px; }
.dtitle { font-family: var(--font-display); font-size: var(--t4); font-weight: 620; letter-spacing: -.01em; }
.meta { display: grid; grid-template-columns: 1fr 1fr; gap: 9px 18px; margin: 14px 0 20px; }
.meta .k { color: var(--muted); font-size: var(--t1); text-transform: uppercase; letter-spacing: .07em; font-weight: 650; }
.meta .v { font-weight: 600; }
.sec { font-size: var(--t1); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 10px; font-weight: 700; }
.leg { position: relative; padding-left: 26px; margin-bottom: 4px; }
.leg::before { content: ""; position: absolute; left: 8px; top: 22px; bottom: -6px; width: 2px; background: var(--line-strong); }
.leg:last-child::before { display: none; }
.leg .dot { position: absolute; left: 2px; top: 4px; width: 14px; height: 14px; border-radius: 50%; border: 3px solid var(--panel); }
.leg.air .dot { background: var(--air); } .leg.sur .dot { background: var(--idle); }
.leg .h { font-weight: 650; }
.leg .h .mode { font-size: var(--t1); padding: 1.5px 7px; border-radius: var(--r-sm); margin-right: 8px; letter-spacing: .05em; }
.leg.air .mode { background: var(--air-bg); color: var(--air); } .leg.sur .mode { background: var(--idle-bg); color: var(--idle); }
.leg .times { color: var(--muted); font-size: var(--t2); margin: 3px 0 13px; font-family: var(--font-mono); }
.ev { display: grid; grid-template-columns: 96px 46px 1fr; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--line); font-size: var(--t2); }
.ev .t { color: var(--muted); font-family: var(--font-mono); font-size: var(--t2); } .ev .c { font-weight: 700; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag { background: var(--chip); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 3px 9px; font-size: var(--t1); font-family: var(--font-mono); }
.empty { color: var(--muted); text-align: center; padding: 60px 20px; }

/* ---- mapa (Leaflet + OSM/CARTO) ---- */
.tgl {
  font: inherit; font-size: var(--t2); font-weight: 600; border: 1px solid var(--line-strong);
  background: var(--panel); color: var(--muted); border-radius: var(--r-full); padding: 5px 13px;
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.tgl.on { border-color: var(--brand); color: var(--brand); background: var(--chip); }
.tgl:disabled { opacity: .45; cursor: not-allowed; }
/* controle segmentado dos submodos do mapa (tudo | aéreo | rodoviário) */
.seg {
  display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-full);
  overflow: hidden; background: var(--panel); flex: none;
}
.seg button {
  font: 600 var(--t2) var(--font-body); border: 0; background: none; color: var(--muted);
  padding: 6px 14px; cursor: pointer; transition: background .15s, color .15s;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--brand); color: var(--brand-ink); }
.seg button:hover:not(.on) { color: var(--ink); background: var(--chip); }
/* filtros específicos do modo, ao lado do segmentado */
.modo-filtros { display: inline-flex; gap: 8px; align-items: center; }
.modo-filtros:empty { display: none; }
.modo-filtros select {
  font: 600 var(--t2) var(--font-body); color: var(--ink); background: var(--panel);
  border: 1px solid var(--line-strong); border-radius: var(--r-full); padding: 5px 10px;
}
html.tv .seg, html.tv .modo-filtros { display: none !important; }
.mapa-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 14px; align-items: start; }
.mapa-wrap { position: relative; padding: 10px; }
.mapa-leaflet {
  width: 100%; height: min(72vh, 660px); border-radius: var(--r-md); z-index: 0;
  background: var(--bg); outline: 1px solid var(--line);
}
/* basemap monocromático: OSM colorido vira cinza (o CARTO passou a exigir
   API key); no escuro a mesma imagem é invertida — só o pane dos tiles,
   pontos/rotas/aviões ficam intactos */
.mapa-leaflet .leaflet-tile-pane { filter: grayscale(1) contrast(1.04); }
/* o TEMPO fica fora do filtro monocromático — é a única cor "de dado" nos
   tiles e precisa gritar: chuva no azul do RainViewer (esquema universal),
   nuvens do satélite IV tingidas de azul-gelo */
.mapa-leaflet .leaflet-chuva-pane { filter: saturate(1.6) brightness(1.05); }
.mapa-leaflet .leaflet-nuvens-pane {
  filter: grayscale(1) brightness(1.15) sepia(1) hue-rotate(175deg) saturate(2.2);
}
:root[data-tema="escuro"] .mapa-leaflet .leaflet-chuva-pane {
  filter: saturate(1.8) brightness(1.25);
}
:root[data-tema="escuro"] .mapa-leaflet .leaflet-nuvens-pane {
  filter: grayscale(1) brightness(.9) sepia(1) hue-rotate(185deg) saturate(2.6);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) .mapa-leaflet .leaflet-chuva-pane {
    filter: saturate(1.8) brightness(1.25);
  }
  :root:not([data-tema="claro"]) .mapa-leaflet .leaflet-nuvens-pane {
    filter: grayscale(1) brightness(.9) sepia(1) hue-rotate(185deg) saturate(2.6);
  }
}
:root[data-tema="escuro"] .mapa-leaflet .leaflet-tile-pane {
  filter: grayscale(1) invert(1) brightness(.86) contrast(1.08);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) .mapa-leaflet .leaflet-tile-pane {
    filter: grayscale(1) invert(1) brightness(.86) contrast(1.08);
  }
}
/* Google Maps: tiles coloridos oficiais — sem o filtro monocromático do OSM */
.mapa-leaflet[data-basemap="google"] .leaflet-tile-pane,
:root[data-tema="escuro"] .mapa-leaflet[data-basemap="google"] .leaflet-tile-pane {
  filter: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-tema="claro"]) .mapa-leaflet[data-basemap="google"] .leaflet-tile-pane {
    filter: none;
  }
}
.leaflet-container { font: var(--t2)/1.4 var(--font-body); }
.leaflet-container a { color: var(--muted); }
.leaflet-control-attribution {
  background: color-mix(in srgb, var(--panel) 80%, transparent) !important;
  color: var(--muted); font-size: var(--t1);
}
.leaflet-bar a { background: var(--panel); color: var(--ink); border-color: var(--line); }
.leaflet-bar a:hover { background: var(--chip); }
.leaflet-tooltip {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow); font: var(--t2)/1.45 var(--font-body);
  padding: 8px 11px;
}
.leaflet-tooltip b { font-family: var(--font-display); font-weight: 620; display: block; margin-bottom: 2px; }
.leaflet-tooltip-top:before { border-top-color: var(--line-strong); }

/* pontos e linhas: cor apenas onde é sinal */
.mapa-leaflet .pt { stroke: var(--panel); fill-opacity: .92; }
.mapa-leaflet .pt.wait { fill: var(--wait); stroke: var(--panel); }
/* anel tracejado no ponto morto: sobre o mosaico do mapa a cor sozinha não
   sobrevive, e o tracejado lê como sinal interrompido mesmo sem cor */
.mapa-leaflet .pt.dead {
  fill: var(--dead); stroke: var(--dead); stroke-width: 2.5px; stroke-dasharray: 3 2.5;
}
.mapa-leaflet .pt.ok { fill: var(--ok); }
.mapa-leaflet .pt.sel { stroke: var(--brand); stroke-width: 3px; }
.mapa-leaflet .pt.hubp { fill: var(--brand); }
.mapa-leaflet .rota-linha { stroke: var(--idle); opacity: .45; fill: none; }
.mapa-leaflet .rota-linha.sur { stroke-dasharray: 5 6; }
.mapa-leaflet .perna-real {
  stroke: var(--brand); fill: none; stroke-dasharray: 9 7;
  animation: fluir 1.1s linear infinite;
}
.mapa-leaflet .perna-real.sur { stroke-dasharray: 4 6; }
@keyframes fluir { to { stroke-dashoffset: -16; } }

/* selo de clima ancorado ao ponto: temperatura máxima do dia no destino;
   âmbar quando ≥30°C — risco de excursão térmica na última milha (GDP) */
.clima-badge { width: auto !important; height: auto !important; pointer-events: none; }
.clima-badge .cb {
  display: inline-block; white-space: nowrap;
  background: var(--panel); border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 1.5px 7px; font: 600 var(--t1) var(--font-mono); color: var(--ink);
  box-shadow: var(--sombra-elevada);
}
/* litoral leste: selo abre para a esquerda para não cortar na borda do mapa */
.clima-badge.esq .cb { transform: translateX(calc(-100% - 20px)); }
.clima-badge.quente .cb { border-color: var(--dead); color: var(--dead); }

/* aeronave real (FR24) — o amarelo clássico do FR24, com contorno escuro
 * para não sumir nos tiles claros */
.aviao-vivo svg {
  width: 26px; height: 26px; display: block; fill: var(--fr24);
  filter: drop-shadow(0 1px 2px oklch(0% 0 0 / .4));
}
.aviao-vivo svg path { stroke: var(--fr24-borda); stroke-width: 1; }
.sw-aviao { width: 14px; height: 14px; fill: var(--fr24); margin-right: 5px; vertical-align: -2px; }
.sw-aviao path { stroke: var(--fr24-borda); stroke-width: 1; }
.mapa-leaflet .trilha-voo { stroke: var(--fr24); opacity: .65; fill: none; }

/* caminhão real (Autotrac) — verde em movimento; parado apaga, mudo some aos poucos */
.caminhao-vivo svg {
  width: 22px; height: 22px; display: block; fill: var(--atic);
  filter: drop-shadow(0 1px 2px oklch(0% 0 0 / .35));
}
.caminhao-vivo svg path { stroke: var(--atic-borda); stroke-width: 1; }
.caminhao-vivo.parado svg { fill: var(--idle); opacity: .75; }
.caminhao-vivo.velho svg { opacity: .4; }
.caminhao-vivo.atrasado svg { fill: var(--err); opacity: 1; }
/* selo de temperatura do baú (sensor OBC) colado ao caminhão — âmbar quando
 * foge da faixa clássica de cadeia fria (>8°C), apagado se a leitura é velha */
.caminhao-vivo .ctemp {
  position: absolute; left: 20px; top: -7px;
  font: 600 var(--t1) var(--font-mono); line-height: 1; color: var(--ink);
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
  padding: 2px 4px; white-space: nowrap; pointer-events: none;
}
.caminhao-vivo .ctemp.quente {
  color: var(--dead); border-color: color-mix(in srgb, var(--dead) 60%, var(--line-strong));
  font-weight: 700;
}
.caminhao-vivo .ctemp.velha { opacity: .55; }
html.tv .caminhao-vivo .ctemp { font-size: var(--t2); padding: 3px 5px; }
.mapa-leaflet .rota-frota { stroke: var(--atic); stroke-dasharray: 4 6; opacity: .8; fill: none; }
.mapa-leaflet .trilha-frota { stroke: var(--atic); opacity: .5; fill: none; }
.frota-chk { cursor: pointer; justify-content: flex-start; gap: 8px; }
.frota-chk input { accent-color: var(--atic); margin: 0; }

/* modal de fontes (proveniência): saúde de cada fonte de dados */
.fonte-row { padding: 10px 0; border-top: 1px dashed var(--line); }
.fonte-row:first-child { border-top: none; }
.fonte-topo { display: flex; align-items: center; gap: 8px; }
.fonte-topo b { font-size: var(--t2); }
.fonte-frescor { margin-left: auto; font-size: var(--t1); white-space: nowrap; }
.fonte-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--idle); }
.fonte-dot.ok { background: var(--atic); }
.fonte-dot.velha { background: var(--err); animation: fonte-pulso 1.4s ease-in-out infinite; }
.fonte-dot.aquecendo { background: var(--fr24); }
.fonte-papel { font-size: var(--t2); margin-top: 3px; max-width: 70ch; }
.fonte-detalhe { font-size: var(--t1); margin-top: 3px; color: var(--muted); max-width: 70ch; }
@keyframes fonte-pulso { 50% { opacity: .35; } }

/* chaves de API (dentro do modal de fontes) */
.chaves-sec { margin-top: 14px; border-top: 1px solid var(--line-strong); padding-top: 10px; }
.chaves-grupo { padding: 10px 0; border-top: 1px dashed var(--line); }
.chave-linha { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.chave-linha .k { min-width: 150px; font-size: var(--t1); color: var(--muted); }
.chave-linha input {
  flex: 1; min-width: 0; padding: 5px 8px; font: var(--t2) var(--font-mono);
  background: var(--chip); color: var(--ink);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm);
}
.chave-salvar { margin-top: 8px; }
.zapi-qr { margin-top: 10px; text-align: center; }
.zapi-qr img {
  width: 200px; height: 200px; image-rendering: pixelated;
  background: white; padding: 8px; border-radius: var(--r-md);
}
.zapi-qr .dim { font-size: var(--t1); margin-top: 6px; }
.perfil-alertas {
  margin: 6px 0 10px 24px; padding: 10px 12px;
  border: 1px dashed var(--line-strong); border-radius: var(--r-md);
}
.perfil-alertas .fr24-linha { margin-top: 4px; }
.perfil-desc { font-size: var(--t1); margin: 0 0 6px 24px; }
.chave-ok { color: var(--atic); }
.chave-erro { color: var(--err); }

/* ---- página de administração (/admin.html) ----
 * Reusa a linguagem do modal de chaves; aqui só o que a página pede a mais. */
.chave-linha select {
  background: var(--chip); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 5px 8px; font: var(--t2) var(--font-mono);
}
.admin-nova-pessoa input { flex: initial; width: 170px; }
.admin-nova-pessoa input[type="email"] { width: 210px; }
body.admin .card { margin-bottom: 18px; }
body.admin .card .sub { line-height: 1.5; margin: 2px 0 10px; }
body.admin .card code {
  font-family: var(--font-mono); font-size: var(--t1);
  background: var(--chip); padding: 1px 6px; border-radius: var(--r-sm);
}
body.admin .chave-linha .k { min-width: 210px; }
a.tema { text-decoration: none; }

/* selo do modo demonstração: sempre visível, ninguém confunde com produção */
.selo-demo {
  position: fixed; right: 14px; bottom: 14px; z-index: 12000; pointer-events: none;
  background: var(--fr24); color: oklch(20% 0.02 80);
  font: 700 var(--t2) var(--font-mono); letter-spacing: .4px;
  padding: 6px 12px; border-radius: var(--r-sm); box-shadow: var(--sombra-elevada);
}
.sw-caminhao { width: 14px; height: 14px; fill: var(--atic); margin-right: 5px; vertical-align: -2px; }
.sw-caminhao path { stroke: var(--atic-borda); stroke-width: 1; }

/* ===================== MODO TV (NOC) =====================
 * Legível a 4 metros, zero interação: some o cromo, cresce o essencial. */
html.tv .tabs,
html.tv .tema,
html.tv .btnnav,
html.tv .tgl,
html.tv .fr24-painel,
html.tv .filters,
html.tv .dead-note,
html.tv .foot { display: none !important; }
html.tv body { overflow: hidden; }
html.tv .view { padding-bottom: 0; }
html.tv h1 { font-size: var(--t4); }
html.tv .dia-bar { font-size: var(--t2); }
html.tv .mapa-grid { grid-template-columns: minmax(0, 1.6fr) minmax(300px, .4fr); }
html.tv .mapa-leaflet { height: calc(100vh - 215px); min-height: 480px; }
html.tv .kpis b, html.tv .kpis .big { font-size: var(--t7); }
html.tv .mlegenda { font-size: var(--t2); }

/* tour guiado (?tv=1&tour=1): o painel lateral do mapa vira o cartão da cena */
.tv-cena { display: flex; flex-direction: column; }
.tv-kv {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 7px 0; border-bottom: 1px dashed var(--line);
}
.tv-kv .k { color: var(--muted); font-size: var(--t2); }
.tv-kv .v { text-align: right; font-weight: 600; }
.tv-num { font: 650 var(--t4)/1 var(--font-display); }
.tv-num.ruim { color: var(--dead); }
.tv-cena-rota { display: flex; align-items: center; gap: 8px; font-size: var(--t3); margin-bottom: 6px; }
.tv-cena-prog { display: flex; align-items: center; gap: 10px; margin-top: 14px; color: var(--muted); font-size: var(--t1); }
.tv-cena-barra { flex: 1; height: 3px; border-radius: var(--r-full); background: var(--chip); overflow: hidden; }
.tv-cena-barra .fill { height: 100%; width: 0; background: var(--ink); animation: tv-cena-enche linear forwards; }
@keyframes tv-cena-enche { to { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .tv-cena-barra .fill { animation: none; width: 100%; } }
html.tv .tv-kv { padding: 10px 0; }
html.tv .tv-kv .k { font-size: var(--t2); }
html.tv .tv-kv .v { font-size: var(--t3); }
html.tv .tv-num { font-size: var(--t6); }
html.tv .tv-cena-rota { font-size: var(--t4); }

/* guia do modo TV: modal central com os links prontos */
.tv-ajuda {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(680px, 94vw); max-height: 88vh; overflow: auto; z-index: 1042;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow);
}
.tv-ajuda header { display: flex; align-items: center; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); }
.tv-ajuda header .x {
  margin-left: auto; cursor: pointer; border: 0; background: var(--chip); color: var(--ink);
  width: 30px; height: 30px; border-radius: var(--r-md); font-size: var(--t2);
}
.tv-ajuda .body { padding: 18px 22px; }
.tv-ajuda .sub { color: var(--muted); font-size: var(--t2); line-height: 1.55; margin: 0 0 8px; max-width: 70ch; }
.tv-ajuda code { font-family: var(--font-mono); font-size: var(--t2); background: var(--chip); padding: 1px 6px; border-radius: var(--r-sm); }
.tv-link { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.tv-link:last-child { border-bottom: 0; }
.tv-link .k { min-width: 200px; font-weight: 600; font-size: var(--t2); }
.tv-link a { flex: 1; font-size: var(--t1); color: var(--muted); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-link a:hover { color: var(--ink); text-decoration: underline; }
html.tv #btnTvAjuda, html.tv .tv-ajuda { display: none !important; }
@media (max-width: 760px) {
  .tv-link { flex-wrap: wrap; }
  .tv-link .k { min-width: 100%; }
}

/* relógio de frescor: hora + idade dos dados (vermelho = tela mentindo) */
.tv-relogio { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; margin-left: 14px; }
.tv-relogio b { font: 650 var(--t4) var(--font-mono); letter-spacing: .03em; }
.tv-relogio span { font: 500 var(--t1) var(--font-mono); color: var(--muted); }
.tv-relogio.velho span { color: var(--err); font-weight: 700; }

/* popup de alerta crítico: toma a tela, ninguém precisa clicar */
.tv-popup {
  position: fixed; inset: 0; z-index: 2000; display: grid; place-items: center;
  background: oklch(12% 0.014 300 / .65); backdrop-filter: blur(3px);
}
/* display:grid acima vence o [hidden] nativo do navegador; reafirma aqui */
.tv-popup[hidden] { display: none; }
.tv-popup-card {
  max-width: min(860px, 88vw); padding: 42px 54px; text-align: center;
  background: var(--panel); border-radius: var(--r-xl);
  border: 3px solid var(--err); box-shadow: var(--shadow);
  animation: tv-pulso 1.6s ease-in-out infinite;
}
@keyframes tv-pulso {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--err) 45%, transparent); }
  50% { box-shadow: 0 0 0 18px transparent; }
}
.tv-popup-sev {
  display: inline-block; padding: 3px 14px; border-radius: var(--r-full); margin-bottom: 16px;
  background: var(--err-bg); color: var(--err);
  font: 700 var(--t2) var(--font-mono); text-transform: uppercase; letter-spacing: .12em;
}
.tv-popup-titulo { font-family: var(--font-display); font-size: var(--t6); font-weight: 650; letter-spacing: -.01em; }
.tv-popup-detalhe { margin-top: 10px; font-size: var(--t3); color: var(--muted); white-space: pre-line; }

/* ===================== CURVA TÉRMICA (modal) ===================== */
.curva-modal { width: min(1000px, 96vw); }
.chip.click { cursor: pointer; }
.chip.click:hover { filter: brightness(1.08); }
.curva-svg { width: 100%; height: auto; display: block; }
.cv-faixa { fill: color-mix(in srgb, var(--ok) 10%, transparent); }
.cv-faixa-borda { stroke: color-mix(in srgb, var(--ok) 45%, transparent); stroke-width: 1; stroke-dasharray: 3 4; }
.cv-grade { stroke: var(--line); stroke-width: 1; }
.cv-rotulo { fill: var(--muted); font: 500 var(--t1) var(--font-mono); }
.cv-linha {
  fill: none; stroke: var(--ink); stroke-width: 1.3;
  stroke-opacity: .5; stroke-linejoin: round; stroke-linecap: round;
}
.cv-linha.sel { stroke-opacity: 1; stroke-width: 2; }
.cv-linha.off { stroke-opacity: .08; }
.cv-fora { fill: var(--dead); }
.curva-legenda { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.curva-legenda .sel-chip { outline: 2px solid var(--ink); }
.curva-nota { margin-top: 10px; font-size: var(--t1); color: var(--muted); }

/* ===================== PERFORMANCE (preliminar) =====================
 * Conformidade térmica por caixa com régua crua e memória de cálculo aberta.
 * Cor só na acurácia e nos sinais (conforme/NC/sem leitura). */
.perf-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(235px, 1fr));
  gap: 14px; margin-bottom: 14px;
}
.pfcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--e4) var(--e5);
}
.pfcard.cons { background: color-mix(in srgb, var(--ink) 4%, var(--panel)); }
.pftitulo {
  font-size: var(--t1); letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 10px; font-weight: 600;
}
.pfac {
  font-family: var(--font-display); font-size: var(--t7); font-weight: 700;
  letter-spacing: -.02em; line-height: 1;
}
.pfac.ok { color: var(--ok); }
.pfac.warn { color: var(--warn); }
.pfac.dead { color: var(--dead); }
.pfleg { font-size: var(--t1); color: var(--muted); margin: 4px 0 14px; }
.pfnums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.pfnum b { display: block; font-family: var(--font-mono); font-size: var(--t2); }
.pfnum span { font-size: var(--t1); color: var(--muted); letter-spacing: .02em; }
.pfnum.ok b { color: var(--ok); }
.pfnum.dead b { color: var(--dead); }
.pfnum.wait b { color: var(--muted); }
.perf-tabelas { align-items: start; }
.perf-tab td, .perf-tab th { padding: 7px 10px; }
.pf-dead { color: var(--dead); }
.pfmodal { padding: 12px 0; border-top: 1px solid var(--line); }
.pfmodal:first-child { border-top: 0; }
.pfmodal-cab { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.pfmodal-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.perf-memoria { margin-top: 14px; }
.perf-memoria .memo-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 0 36px;
}
.perf-memoria h4 {
  margin: 16px 0 4px; font-size: var(--t1); letter-spacing: .07em;
  text-transform: uppercase; color: var(--muted);
}
.perf-memoria p, .perf-memoria li { font-size: var(--t2); line-height: 1.55; margin: 4px 0; max-width: 70ch; }
.perf-memoria ul { margin: 4px 0 8px; padding-left: 18px; }
.perf-memoria code {
  font-family: var(--font-mono); font-size: var(--t2);
  background: var(--chip); padding: 1px 5px; border-radius: var(--r-sm);
}

/* ===================== AÉREO × RODOVIÁRIO (painel duplo) =====================
 * Dois quadros lado a lado: aéreo (amarelo FR24 no acento) e rodoviário
 * (verde frota). Cor apenas onde é sinal; na TV a tipografia cresce. */
.modais-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.mcol-cab { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.mcol-cab svg { width: 22px; height: 22px; flex: none; }
#colAereo .mcol-cab svg, #mapasCabAereo .mcol-cab svg { fill: var(--fr24); }
#colAereo .mcol-cab svg path, #mapasCabAereo .mcol-cab svg path { stroke: var(--fr24-borda); stroke-width: 1; }
#colRodo .mcol-cab svg, #mapasCabRodo .mcol-cab svg { fill: var(--atic); }
#colRodo .mcol-cab svg path, #mapasCabRodo .mcol-cab svg path { stroke: var(--atic-borda); stroke-width: 1; }
.mcol-cab b { font-family: var(--font-display); font-size: var(--t3); font-weight: 650; letter-spacing: -.01em; }
.mcol-badge {
  margin-left: auto; font: 600 var(--t2) var(--font-mono); color: var(--muted);
  border: 1px solid var(--line-strong); border-radius: var(--r-full); padding: 3px 11px; white-space: nowrap;
}
.mcol-badge.ar { color: var(--fr24-tinta); border-color: color-mix(in srgb, var(--fr24-tinta) 55%, var(--line-strong)); }
.mcol-badge.rodo { color: var(--atic); border-color: color-mix(in srgb, var(--atic) 55%, var(--line-strong)); }
.mkpis {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
  padding-bottom: 12px; border-bottom: 1px solid var(--line);
}
.mkpi .n {
  font-family: var(--font-display); font-size: var(--t5); font-weight: 600;
  letter-spacing: -.02em; line-height: 1.1; font-variant-numeric: tabular-nums;
}
.mkpi .l { color: var(--muted); font-size: var(--t1); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; margin-top: 2px; }
.mkpi.ok .n { color: var(--ok); }
.mkpi.wait .n { color: var(--wait); }
.mkpi.dead .n { color: var(--dead); }
.mkpi.ar .n { color: var(--fr24-tinta); }
/* barra de progresso por companhia (entregues/total) */
.mbarra { display: flex; align-items: center; gap: 10px; padding: 5px 0; }
.mbarra-rot { min-width: 64px; display: inline-flex; }
.mbarra-track { flex: 1; height: 8px; border-radius: var(--r-full); background: var(--idle-bg); overflow: hidden; }
.mbarra-fill { height: 100%; background: var(--ok); border-radius: var(--r-full); transition: width .6s cubic-bezier(.16,1,.3,1); }
.mbarra-val { font-size: var(--t2); color: var(--muted); min-width: 52px; text-align: right; }
/* fileira de voo/viagem (lista viva de cada coluna) */
.mvrow { display: flex; align-items: center; gap: 10px; padding: 8px 2px; border-top: 1px dashed var(--line); }
.mvrow.click { cursor: pointer; transition: background .12s; }
.mvrow.click:hover { background: var(--chip); }
.mv-tx { min-width: 0; flex: 1; }
.mv-h { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: var(--t2); }
/* régua de temperatura do baú: faixa fria 2–8°C sombreada, ponto = leitura */
.trow { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.trow-placa { min-width: 84px; font-weight: 600; font-size: var(--t2); }
.trow-track { flex: 1; position: relative; height: 10px; border-radius: var(--r-full); background: var(--idle-bg); }
.trow-faixa {
  position: absolute; top: 0; bottom: 0; border-radius: var(--r-full);
  background: color-mix(in srgb, var(--ok) 24%, transparent);
}
.trow-dot {
  position: absolute; top: 50%; width: 12px; height: 12px; border-radius: 50%;
  background: var(--atic); border: 2px solid var(--panel);
  transform: translate(-50%, -50%); box-shadow: var(--sombra-elevada);
}
.trow.quente .trow-dot { background: var(--dead); }
.trow-val { min-width: 56px; text-align: right; font-size: var(--t2); font-weight: 600; }
.trow.quente .trow-val { color: var(--dead); }
.trow.velha { opacity: .55; }

/* na TV o painel duplo ocupa a tela e cresce para leitura a 4 metros */
html.tv .modais-grid { gap: 22px; }
html.tv .mcol { padding: 26px 30px; min-height: calc(100vh - 210px); }
html.tv .mcol-cab b { font-size: var(--t5); }
html.tv .mcol-cab svg { width: 30px; height: 30px; }
html.tv .mcol-badge { font-size: var(--t2); }
html.tv .mkpi .n { font-size: var(--t7); }
html.tv .mkpi .l { font-size: var(--t2); }
html.tv .mv-h { font-size: var(--t3); }
html.tv .mvrow .sub { font-size: var(--t2); }
html.tv .mbarra-val, html.tv .trow-placa, html.tv .trow-val { font-size: var(--t2); }
html.tv .mbarra-track { height: 11px; }
html.tv .trow-track { height: 13px; }

/* ===================== MAPA DUPLO (aéreo | rodoviário) ===================== */
.mapas-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
.mapa2-wrap { padding: 12px 14px 14px; }
.mapa2-wrap .mcol-cab { margin-bottom: 10px; }
.mapa2 { height: min(68vh, 620px); }
@media (max-width: 900px) {
  .mapas-grid { grid-template-columns: 1fr; }
  .mapa2 { height: 44dvh; }
}
/* na TV os dois mapas dividem a tela inteira */
html.tv .mapas-grid { gap: 18px; }
html.tv .mapa2 { height: calc(100vh - 235px); min-height: 460px; }
html.tv .mapa2-wrap .mcol-cab b { font-size: var(--t4); }
html.tv .mapa2-wrap .mcol-cab svg { width: 26px; height: 26px; }
html.tv .mapa2-wrap .mcol-badge { font-size: var(--t2); }

/* ===================== PLACAR (carrossel para TV) =====================
 * Números de 4 metros; cor apenas onde é sinal (entregue, no ar, sem logger,
 * problema). O carrossel troca a grade inteira com revelação escalonada. */
.placar-dots { display: inline-flex; gap: 7px; align-items: center; }
.pdot { width: 8px; height: 8px; border-radius: 50%; background: var(--chip); border: 1px solid var(--line-strong); }
.pdot.on { background: var(--ink); border-color: var(--ink); }
.pdot.ruim { border-color: var(--err); }
.pdot.ruim.on { background: var(--err); }

.placar-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; margin-top: 4px; }
.pcard {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 20px 24px; display: flex; flex-direction: column; gap: 12px; min-height: 150px;
}
.placar-grid.anima .pcard {
  animation: pcard-in .55s cubic-bezier(.2, .7, .2, 1) backwards;
  animation-delay: calc(var(--i, 0) * 80ms);
}
@keyframes pcard-in { from { opacity: 0; transform: translateY(16px) scale(.985); } }
.pcard.vazio { justify-content: center; align-items: center; color: var(--muted); font-size: var(--t3); }

.ptopo { display: flex; align-items: center; gap: 10px; }
.ptopo .logo-cia { height: 20px; filter: none; } /* no placar a marca aparece */
.ptopo .logo-cia.gol { height: 27px; }
.ptopo .logo-cia.azul { height: 21px; }
.pnome { font-family: var(--font-display); font-size: var(--t3); font-weight: 650; }
.ptotal { margin-left: auto; color: var(--muted); font: 500 var(--t2) var(--font-mono); }
.pnum-linha { display: flex; align-items: baseline; gap: 8px; }
.pnum { font: 650 var(--t7)/1 var(--font-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.pnum.ok { color: var(--ok); }
.pnum.air { color: var(--air); }
.pnum.fr24 { color: var(--fr24-tinta); }
.pnum.dead { color: var(--dead); }
.pnum.grande { font-size: var(--t8); }
.pde { color: var(--muted); font-size: var(--t2); }
.ppct { margin-left: auto; font: 650 var(--t4) var(--font-display); color: var(--muted); }
.pbar { height: 7px; border-radius: var(--r-full); background: var(--chip); overflow: hidden; }
.pbar .fill { height: 100%; background: var(--ok); border-radius: var(--r-full); transition: width .8s var(--ease); }
.pmini-linha { display: flex; gap: 16px; flex-wrap: wrap; }
.pmini { color: var(--muted); font-size: var(--t2); font-weight: 600; }
.pmini.fr24 { color: var(--fr24-tinta); }
/* no placar a leitura é a quatro metros e a cor pode não chegar: o ponto morto
   leva a mesma marca quadrada dos chips (ver .st.dead) */
.pmini.dead { color: var(--dead); display: inline-flex; align-items: center; gap: .4em; }
.pmini.dead::before {
  content: ""; flex: none; width: .62em; height: .62em;
  background: currentColor; border-radius: 1px;
}

.prot { font-family: var(--font-display); font-size: var(--t3); font-weight: 650; }
.pquebra { display: flex; gap: 18px; flex-wrap: wrap; margin-top: auto; align-items: center; }
.pqitem { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); }
.pqitem b { font-family: var(--font-display); font-size: var(--t3); color: var(--ink); }

/* severidade sobe de camada e assume o contorno inteiro. Filete lateral
   colorido é proibido: ver "A Regra da Subida" no DESIGN.md. */
.pcard.problema { background: var(--critica); border-color: var(--line-strong); }
.pcard.problema.critico { border-color: var(--err); box-shadow: var(--sombra-critica); }
.pcard.problema.click { cursor: pointer; }
.pcard.problema.click:hover { box-shadow: var(--sombra-elevada); }
.psev {
  align-self: flex-start; padding: 2px 12px; border-radius: var(--r-full);
  font: 700 var(--t1) var(--font-mono); text-transform: uppercase; letter-spacing: .1em;
}
.psev.err { background: var(--err-bg); color: var(--err); }
.psev.warn { background: var(--warn-bg); color: var(--warn); }
.pdetalhe { color: var(--muted); font-size: var(--t2); line-height: 1.5; max-width: 70ch; }

/* na TV tudo cresce (leitura a 4 metros) e a grade ocupa a tela inteira */
html.tv .placar-grid { gap: 22px; min-height: calc(100vh - 190px); align-content: center; }
html.tv .pcard { padding: 30px 36px; min-height: 240px; justify-content: center; }
html.tv .ptopo .logo-cia { height: 30px; }
html.tv .ptopo .logo-cia.gol { height: 40px; }
html.tv .ptopo .logo-cia.azul { height: 31px; }
html.tv .pnome { font-size: var(--t5); }
html.tv .pnum { font-size: var(--t9); }
html.tv .pnum.grande { font-size: var(--t10); }
html.tv .pde { font-size: var(--t3); }
html.tv .ppct { font-size: var(--t6); }
html.tv .prot { font-size: var(--t4); }
html.tv .pmini { font-size: var(--t3); }
/* no placar o ponto morto ganha a linha inteira. Com a marca ele já não cabia
   ao lado dos outros dois em alguns cartões e quebrava só neles; entre quebrar
   por acaso e quebrar sempre, quebrar sempre é o que fica consistente — e
   isolar o único número ruim do cartão é o que se quer a quatro metros. */
html.tv .pmini.dead { flex-basis: 100%; }
html.tv .pdetalhe { font-size: var(--t3); }
html.tv .pqitem b { font-size: var(--t4); }
@media (prefers-reduced-motion: reduce) { .placar-grid.anima .pcard { animation: none; } }

/* menções a AWB são portas para o rastreio ao vivo */
.awb-link { cursor: pointer; text-decoration: underline dotted transparent; text-underline-offset: 3px; }
.awb-link:hover { color: var(--ink); text-decoration-color: var(--ink); }
.tv-popup-item {
  cursor: pointer; padding: 4px 12px; margin: 2px auto; border-radius: var(--r-sm); width: fit-content;
}
.tv-popup-item:hover { background: var(--chip); color: var(--ink); }
.tv-abrivel { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; }
.tv-abrivel:hover { opacity: .8; }

/* barra persistente de alertas abertos */
.tv-barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 1500;
  padding: 9px 20px; font: 600 var(--t2) var(--font-mono);
  background: var(--warn-bg); color: var(--warn);
  border-top: 2px solid var(--line-strong);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tv-barra.critico {
  background: var(--err-bg); color: var(--err); border-top-color: var(--err);
  /* pulso contínuo: crítico aberto nunca vira paisagem */
  animation: barra-pulso 2.4s ease-in-out infinite;
}
@keyframes barra-pulso {
  0%, 100% { background: var(--err-bg); box-shadow: none; }
  50% {
    background: color-mix(in srgb, var(--err) 26%, var(--err-bg));
    box-shadow: 0 -6px 22px color-mix(in srgb, var(--err) 35%, transparent);
  }
}
@media (prefers-reduced-motion: reduce) {
  .tv-popup-card, .tv-barra.critico { animation: none; }
}

/* painel FR24: modo, ritmo do poll e consumo de créditos */
.fr24-painel {
  margin: 0 0 12px; padding: 12px 16px; max-width: 560px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
  font-size: var(--t2); display: flex; flex-direction: column; gap: 7px;
}
/* o display:flex acima venceria o [hidden] nativo; reafirma aqui */
.fr24-painel[hidden] { display: none; }
.fr24-linha { display: flex; align-items: center; gap: 10px; }
.fr24-linha .k { color: var(--muted); min-width: 130px; }
.fr24-linha select {
  background: var(--chip); color: var(--ink); border: 1px solid var(--line-strong);
  border-radius: var(--r-sm); padding: 3px 8px; font: inherit;
}
.fr24-sec { color: var(--muted); font-size: var(--t1); margin-top: 4px; }
/* histórico de viagens por placa (modal aberto pela busca global) */
.placa-viagem { padding: 10px 0; border-bottom: 1px solid var(--line); }
.placa-viagem:last-child { border-bottom: 0; }
.pv-cab { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pv-sub { font-size: var(--t2); color: var(--muted); margin-top: 3px; }

/* faixa de dado velho da frota (fonte Aura acima do limiar de frescor) */
.frota-velha {
  background: var(--warn-bg); color: var(--warn);
  font-size: var(--t1); font-weight: 600;
  padding: 5px 8px; border-radius: var(--r-sm); margin: 2px 0 6px;
}
.fr24-painel .tgl { align-self: flex-start; }

/* drawer: bloco "aeronave agora" (FR24) */
.aviao-agora {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  border: 1px solid color-mix(in srgb, var(--air) 40%, var(--line));
  background: var(--air-bg); border-radius: var(--r-lg); margin-bottom: 6px;
}
.aviao-agora svg { width: 22px; height: 22px; fill: var(--air); flex: none; }
.aviao-agora .h { font-weight: 650; }

/* legenda + como ler o mapa: no desktop sempre abertas (o summary some);
   no celular viram "ver detalhes" recolhido — regras no bloco mobile */
.mapa-detalhes summary { display: none; }
.mlegenda { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: var(--t2); color: var(--muted); align-items: center; padding: 0 6px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 5px; vertical-align: -1px; }
/* a amostra repete o anel tracejado do ponto no mapa: legenda que só troca de
   cor não ajuda quem não distingue a cor */
.sw-dead { outline: 2px dashed var(--dead); outline-offset: 1.5px; }
.swl { display: inline-block; width: 18px; height: 0; border-top: 2px solid var(--idle); margin-right: 5px; vertical-align: 3px; }
.swl.sur { border-top-style: dashed; border-top-color: var(--idle); }
.swl.real { border-top-width: 3px; border-top-color: var(--brand); }
.mrow { display: flex; align-items: center; gap: 8px; padding: 9px 2px; border-top: 1px dashed var(--line); font-size: var(--t2); flex-wrap: wrap; }
.mrow.click { cursor: pointer; transition: background .12s; } .mrow.click:hover { background: var(--chip); }
.mrow .mlead { font-weight: 600; font-family: var(--font-mono); font-size: var(--t2); }
.mapa-wrap .dead-note { padding: 12px 6px 2px; }

.tema {
  border: 0; background: none; color: var(--band-muted); cursor: pointer;
  width: 32px; height: 32px; border-radius: var(--r-md); display: grid; place-items: center;
  transition: color .15s, background .15s;
}
.tema:hover { color: var(--band-ink); background: oklch(100% 0 0 / .08); }
.tema svg { width: 17px; height: 17px; }

/* ================= mobile: casca de app nativo ================= */
.bottomnav { display: none; } /* só existe no celular */
html.tv .bottomnav { display: none !important; }

/* ===================== NAVEGAÇÃO LATERAL (desktop) =====================
 * Padrão console (Google Admin/M365): cabeçalho fixo no topo, menu à
 * esquerda com seções e submenus, recolhível para trilho de ícones
 * (hambúrguer no cabeçalho; estado persistido). Celular continua com a
 * bottomnav (painel) / abas roláveis (administração); TV esconde tudo. */
.hamb, .sidenav { display: none; }

@media (min-width: 761px) {
  :root { --topo-h: 60px; --nav-w: 240px; --nav-mini: 64px; --ia-w: 336px; }

  body.com-nav {
    --col-nav: var(--nav-w);
    --col-ia: 0px; /* painel da IA fechado: a coluna colapsa */
    display: grid;
    grid-template-columns: var(--col-nav) minmax(0, 1fr) var(--col-ia);
    grid-template-rows: var(--topo-h) 1fr;
    min-height: 100vh;
  }
  html.nav-mini body.com-nav { --col-nav: var(--nav-mini); }
  html.ia-on body.com-nav { --col-ia: var(--ia-w); }
  body.com-nav > header.top {
    grid-column: 1 / -1; grid-row: 1;
    position: sticky; top: 0; z-index: 1035;
    height: var(--topo-h); padding-top: 0; padding-bottom: 0;
  }
  body.com-nav > .view { grid-column: 2; grid-row: 2; }
  /* abas do topo (administração) dão lugar ao menu lateral no desktop */
  body.com-nav > .tabs { display: none; }

  .hamb {
    display: grid; place-items: center; flex: none;
    width: 36px; height: 36px; margin-right: 2px;
    border: 0; border-radius: var(--r-md); background: none; cursor: pointer;
    color: var(--band-muted); transition: color .15s, background .15s;
  }
  .hamb:hover { color: var(--band-ink); background: oklch(100% 0 0 / .08); }
  .hamb svg { width: 19px; height: 19px; }

  .sidenav {
    display: flex; flex-direction: column; gap: 1px;
    grid-column: 1; grid-row: 2;
    position: sticky; top: var(--topo-h);
    height: calc(100vh - var(--topo-h)); overflow-y: auto; overflow-x: hidden;
    padding: 14px 10px 18px;
    background: var(--panel); border-right: 1px solid var(--line);
    scrollbar-width: thin;
  }
  .sidenav .snav-sec {
    font-size: var(--t1); text-transform: uppercase; letter-spacing: .09em;
    font-weight: 700; color: var(--muted);
    margin: 16px 10px 6px; white-space: nowrap;
  }
  .sidenav .snav-sec:first-child { margin-top: 2px; }
  .sidenav .tab, .sidenav .snav-link {
    display: flex; align-items: center; gap: 11px;
    font: inherit; font-weight: 600; font-size: var(--t2); color: var(--muted);
    background: none; border: 0; border-radius: var(--r-md); cursor: pointer;
    padding: 9px 12px; text-align: left; text-decoration: none;
    white-space: nowrap; transition: color .15s, background .15s;
  }
  .sidenav .tab::after { display: none; } /* sem o sublinhado das abas do topo */
  .sidenav .tab svg, .sidenav .snav-link svg { width: 20px; height: 20px; flex: none; }
  .sidenav .tab:hover, .sidenav .snav-link:hover { color: var(--ink); background: var(--chip); }
  .sidenav .tab.active { color: var(--brand); background: var(--chip); }
  .sidenav .lbl { overflow: hidden; text-overflow: ellipsis; }

  /* submenu: itens filhos da visão ativa (ex.: abas da Performance) */
  .snav-sub { display: flex; flex-direction: column; gap: 1px; margin: 1px 0 3px; }
  .snav-sub[hidden] { display: none; }
  .snav-subitem {
    display: flex; align-items: center; gap: 9px;
    font: inherit; font-size: var(--t2); font-weight: 550; color: var(--muted);
    background: none; border: 0; border-radius: var(--r-md); cursor: pointer;
    padding: 6px 12px 6px 26px; text-align: left; white-space: nowrap;
    transition: color .15s, background .15s;
  }
  .snav-subitem::before {
    content: ""; width: 4px; height: 4px; border-radius: 50%;
    background: currentColor; flex: none; opacity: .55;
  }
  .snav-subitem:hover { color: var(--ink); background: var(--chip); }
  .snav-subitem.active { color: var(--brand); background: var(--chip); }

  .sidenav .snav-fim { margin-top: auto; padding-top: 10px; border-top: 1px dashed var(--line); }

  /* trilho recolhido: só ícones (rótulos, seções e submenus somem) */
  html.nav-mini .sidenav { padding-left: 8px; padding-right: 8px; }
  html.nav-mini .sidenav .lbl,
  html.nav-mini .sidenav .snav-sec,
  html.nav-mini .sidenav .snav-sub { display: none; }
  html.nav-mini .sidenav .tab, html.nav-mini .sidenav .snav-link {
    justify-content: center; padding: 11px 0; width: 100%;
  }
}
html.tv .sidenav, html.tv .hamb { display: none !important; }
html.tv body.com-nav { display: block; }

/* ===================== PULSO IA · monitor do plantão (direita) =====================
 * Painel persistente estilo gerenciador de tarefas: mini-monitores com
 * histórico (sparklines), briefing da IA e "pergunte ao Pulso" — a IA toda
 * num lugar só. Botão ✦ do cabeçalho abre/oculta; estado persiste. */
.ia-lat { display: none; }
html.ia-on .ia-lat {
  display: flex; flex-direction: column;
  background: var(--panel); border-left: 1px solid var(--line);
}
@media (min-width: 761px) {
  html.ia-on .ia-lat {
    grid-column: 3; grid-row: 2;
    position: sticky; top: var(--topo-h);
    height: calc(100vh - var(--topo-h));
    min-width: 0; overflow: hidden;
  }
}
@media (max-width: 760px) {
  /* no celular vira uma folha sobreposta pela direita */
  html.ia-on .ia-lat {
    position: fixed; top: 0; right: 0; bottom: 0; z-index: 1036;
    width: min(94vw, 370px); box-shadow: var(--shadow);
    padding-top: env(safe-area-inset-top);
  }
}
html.tv .ia-lat, html.tv #btnIa { display: none !important; }

.ia-lat-topo {
  display: flex; align-items: center; gap: 8px; flex: none;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  font-size: var(--t2);
}
.ia-lat-topo b { font-family: var(--font-display); font-size: var(--t2); letter-spacing: -.01em; }
.ia-lat-topo .dim { font-size: var(--t1); }
.ia-lat-topo .x {
  cursor: pointer; border: 0; background: var(--chip); color: var(--ink);
  width: 26px; height: 26px; border-radius: var(--r-sm); font-size: var(--t2); flex: none;
}
.ia-lat-dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--idle);
}
.ia-lat-dot.on { background: var(--atic); animation: fonte-pulso 2.2s ease-in-out infinite; }
.ia-lat-dot.alerta { background: var(--err); animation: fonte-pulso 1.2s ease-in-out infinite; }

.ia-lat-corpo { flex: 1; overflow-y: auto; padding: 12px 14px 16px; scrollbar-width: thin; }
.ia-lat-pe {
  flex: none; padding: 8px 14px calc(9px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line); font-size: var(--t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* mini-monitores: grade 2×N de "janelinhas" com sparkline, à la gerenciador
 * de tarefas — o traço colore só quando o aspecto vira sinal */
.ia-mon { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ia-mini {
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 8px 10px 6px; min-width: 0; cursor: default;
  transition: border-color .3s;
}
.ia-mini .t {
  font-size: var(--t1); font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ia-mini .v {
  font-family: var(--font-mono); font-size: var(--t3); font-weight: 600; line-height: 1.25;
}
.ia-mini .v small { font-size: var(--t1); color: var(--muted); font-weight: 400; }
.ia-mini svg { display: block; width: 100%; height: 30px; margin-top: 2px; }
.ia-mini .linha { fill: none; stroke: currentColor; stroke-width: 1.6; }
.ia-mini .area { fill: currentColor; opacity: .13; stroke: none; }
.ia-mini { color: var(--muted); }
.ia-mini.ok { color: var(--ok); }
.ia-mini.alerta { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, var(--line)); }
.ia-mini.atencao { color: var(--dead); }
.ia-mini .t { color: var(--muted); }
.ia-mini .v { color: var(--ink); }
.ia-mini .v b { font-weight: 600; }
.ia-mini.alerta .v b { color: var(--err); }
.ia-mini.atencao .v b { color: var(--dead); }

/* seções do painel (briefing, pergunta) */
.ia-sec { margin-top: 16px; padding-top: 12px; border-top: 1px solid var(--line); }
.ia-sec-h { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: var(--t2); }
.ia-sec-h .dim { font-size: var(--t1); }
.ia-sec code { font-family: var(--font-mono); font-size: var(--t1); background: var(--chip); padding: 1px 5px; border-radius: var(--r-sm); }
.ia-lat .ia-pergunta { display: flex; gap: 6px; }
.ia-lat .ia-pergunta input { min-width: 0; }
.ia-lat .dead-note { margin-top: 14px; }

@media (max-width: 900px) {
  .mapa-grid { grid-template-columns: 1fr; }
  .cards2 { grid-template-columns: 1fr; }
  .modais-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  html, body { overflow-x: clip; }
  body { -webkit-tap-highlight-color: transparent; }
  button, .tab, .tgl, .btn, .btnnav, tbody tr.click { touch-action: manipulation; }
  header.top, .bottomnav { -webkit-user-select: none; user-select: none; }

  /* app bar fixa, cobrindo o notch/status bar (standalone PWA inclusive);
     z-index abaixo do scrim (1040): o bottom sheet escurece a tela inteira */
  header.top {
    position: sticky; top: 0; z-index: 1030;
    padding: calc(10px + env(safe-area-inset-top)) 14px 10px; gap: 8px;
  }
  .ecg { width: 54px; height: 20px; }
  h1 { font-size: var(--t3); }
  h1 small { font-size: var(--t1); }
  .updated, #btnTvAjuda { display: none; }
  .tema { width: 40px; height: 40px; }

  /* navegação vai para o polegar: abas do topo somem, entra a barra inferior */
  .tabs { display: none; }
  /* a administração não tem bottomnav: as abas ficam, rolando de lado */
  body.admin .tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
  body.admin .tabs::-webkit-scrollbar { display: none; }
  .bottomnav {
    display: grid; grid-template-columns: repeat(6, 1fr);
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    background: color-mix(in srgb, var(--panel) 86%, transparent);
    -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    padding: 6px 6px calc(8px + env(safe-area-inset-bottom));
  }
  .bottomnav .tab {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 4px 0 2px; min-height: 52px; border: 0; background: none;
    font-size: var(--t1); font-weight: 650; letter-spacing: .02em; color: var(--muted);
    transition: color .2s;
  }
  .bottomnav .tab::after { display: none; }
  .bottomnav .tab svg {
    box-sizing: content-box; /* o pill é o padding em volta do ícone */
    width: 22px; height: 22px; padding: 4px 10px; border-radius: var(--r-full);
    transition: background .3s cubic-bezier(.16,1,.3,1), transform .18s cubic-bezier(.16,1,.3,1);
  }
  .bottomnav .tab.active { color: var(--brand); }
  .bottomnav .tab.active svg { background: var(--chip); }
  .bottomnav .tab:active svg { transform: scale(.9); }

  /* conteúdo: entra deslizando como troca de tela; respiro para a barra */
  .view { padding: 14px 14px calc(88px + env(safe-area-inset-bottom)); }
  .view:not([hidden]) { animation: view-in .26s cubic-bezier(.16,1,.3,1); }

  .kpis { grid-template-columns: repeat(2, 1fr); row-gap: 14px; }
  .kpi { padding: 4px 14px 0; }
  .kpi:nth-child(odd) { border-left: 0; padding-left: 2px; }
  .kpi .n { font-size: var(--t5); }

  /* fileiras de controles rolam de lado, como chips nativos */
  .dia-bar {
    flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none;
    margin: 0 -14px 14px; padding: 2px 14px; row-gap: 8px;
  }
  .dia-bar::-webkit-scrollbar { display: none; }
  .dia-bar > * { flex: none; }
  .dia-bar .grow, .dia-bar .dim { display: none; }
  .tgl { padding: 9px 15px; }
  .btnnav { width: 40px; height: 40px; }

  /* 16px nos campos: iOS não dá zoom forçado ao focar */
  .filters input, .filters select, .dia-bar input[type=date],
  /* 16px é exigência do iOS (abaixo disso o Safari dá zoom no foco), e por
     isso é a única exceção autorizada à escala tipográfica */
  .ia-pergunta input, .chave-linha input { font-size: 16px; }
  #busca, #diaBusca {
    min-width: 0; width: 100%; max-width: none; flex-basis: 100%;
    padding: 11px 14px; border-radius: var(--r-lg);
  }
  .filters { gap: 8px; }
  .filters select { flex: 1 1 calc(50% - 4px); min-width: 0; max-width: 100%; padding: 10px 12px; border-radius: var(--r-lg); }
  .filters .btn { flex: 1 1 100%; min-height: 46px; border-radius: var(--r-lg); }
  .view, .card { min-width: 0; max-width: 100%; }
  .count { flex-basis: 100%; margin-left: 0; }

  .mapa-leaflet { height: 58dvh; }
  .selo-demo { bottom: calc(80px + env(safe-area-inset-bottom)); }

  /* legenda e orientações do mapa recolhidas atrás de "ver detalhes" */
  .mapa-detalhes summary {
    display: flex; align-items: center; justify-content: center; gap: 9px;
    list-style: none; cursor: pointer; -webkit-user-select: none; user-select: none;
    margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-lg);
    color: var(--muted); font-size: var(--t2); font-weight: 650;
  }
  .mapa-detalhes summary::-webkit-details-marker { display: none; }
  .mapa-detalhes summary::after {
    content: ""; width: 7px; height: 7px; flex: none; margin-top: -4px;
    border-right: 1.8px solid currentColor; border-bottom: 1.8px solid currentColor;
    transform: rotate(45deg); transition: transform .25s cubic-bezier(.16,1,.3,1);
  }
  .mapa-detalhes[open] summary::after { transform: rotate(225deg); margin-top: 4px; }

  /* tabelas viram cartões empilhados; o rótulo vem do data-r de cada célula */
  table { background: none; border: 0; box-shadow: none; }
  table, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-lg);
    padding: var(--e3) var(--e4); margin-bottom: var(--e2);
  }
  tbody tr.click:hover { box-shadow: var(--sombra-elevada); }
  /* toque com resposta física: o cartão afunda sob o dedo */
  tbody tr.click { transition: transform .18s cubic-bezier(.16,1,.3,1), background .18s; }
  tbody tr.click:active { transform: scale(.982); background: var(--chip); }
  .mrow.click:active, .pcard.problema.click:active, .chip.click:active { background: var(--chip); }
  tbody td { border: 0; padding: 4px 0; }
  tbody td:empty { display: none; }
  tbody td::before {
    content: attr(data-r); display: block; font-size: var(--t1); text-transform: uppercase;
    letter-spacing: .08em; color: var(--muted); font-weight: 700; margin-bottom: 1px;
  }
  tbody td:not([data-r])::before { display: none; }
  tbody tr.sentinela { background: none; border: 0; box-shadow: none; }

  /* drawer vira bottom sheet: sobe de baixo, alça de arrastar, cantos redondos */
  .drawer {
    top: auto; left: 0; right: 0; bottom: 0; width: 100%;
    height: min(92dvh, 100%);
    border-left: 0; border-top: 1px solid var(--line);
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform: translateY(100%);
  }
  .drawer::before {
    content: ""; position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
    width: 40px; height: 4px; border-radius: var(--r-full); background: var(--line-strong);
  }
  .drawer header { padding: 22px 18px 14px; touch-action: none; cursor: grab; }
  .drawer .body { padding: 14px 18px calc(22px + env(safe-area-inset-bottom)); }

  /* modais centrais também viram sheets */
  .tv-ajuda {
    top: auto; bottom: 0; left: 0; transform: none;
    width: 100%; max-height: 86dvh; border-radius: var(--r-xl) var(--r-xl) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
}
@keyframes view-in { from { opacity: 0; transform: translateY(10px); } }

/* ---- IA · análise do Pulso (card do painel do dia) ---- */
.ia-card { margin-bottom: 22px; }
.ia-card h3 { display: flex; align-items: center; gap: 10px; }
.ia-card h3 .grow { flex: 1; }
.ia-texto { font-size: var(--t2); line-height: 1.55; color: var(--ink); max-width: 70ch; }
/* cada bullet do briefing vira uma linha com selo de severidade e filete
 * colorido — a hierarquia visual do NOC (crítico salta, info recua) */
.ia-linha {
  display: flex; align-items: baseline; gap: var(--e3);
  padding: var(--e2) var(--e3); margin: var(--e1) 0;
  border: 1px solid transparent; border-radius: var(--r-sm);
  background: color-mix(in oklab, var(--chip) 55%, transparent);
}
.ia-linha .chip.st { flex: none; margin-top: 1px; }
.ia-linha.sev-err { border-color: color-mix(in oklab, var(--err) 55%, transparent); background: color-mix(in oklab, var(--err-bg) 42%, transparent); }
.ia-linha.sev-dead { border-color: color-mix(in oklab, var(--dead) 55%, transparent); background: color-mix(in oklab, var(--dead-bg) 42%, transparent); }
.ia-linha.sev-air { border-color: color-mix(in oklab, var(--air) 40%, transparent); }
.ia-linha.sev-ok { border-color: color-mix(in oklab, var(--ok) 40%, transparent); }
.ia-ponto { color: var(--muted); flex: none; }
.ia-corpo { flex: 1; min-width: 0; }
.ia-chip {
  display: inline-block; padding: 0 6px; margin: 0 1px; border-radius: var(--r-sm);
  font-size: var(--t2); background: var(--panel); border: 1px solid var(--line-strong);
  white-space: nowrap;
}
a.ia-chip.clique { color: var(--air); text-decoration: none; cursor: pointer; }
a.ia-chip.clique:hover { filter: brightness(1.12); border-color: var(--air); }
.ia-pergunta { display: flex; gap: 10px; margin-top: 14px; }
.ia-pergunta input {
  flex: 1; font: 500 var(--t2) var(--font-sans, inherit); color: var(--ink);
  background: var(--panel); border: 1px solid var(--line-strong);
  border-radius: var(--r-md); padding: 9px 12px; min-width: 0;
}
.ia-resposta {
  margin-top: 12px; padding: 10px 14px; border: 1px dashed var(--line-strong);
  border-radius: var(--r-md); font-size: var(--t2); line-height: 1.55;
}
.ia-r-fontes { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); font-size: var(--t1); }

/* ===================== chamados (IA condutora) =====================
 * Lista à esquerda, conversa à direita — a timeline mistura balões de
 * mensagem (enviada/recebida) com o raciocínio da IA e eventos de sistema. */
.ch-badge {
  margin-left: auto; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: var(--r-full); background: var(--err); color: oklch(98% 0 0);
  font-size: 11px; font-weight: 700; display: inline-flex;
  align-items: center; justify-content: center;
}
html.nav-mini .ch-badge { display: none; }

.ch-form { margin-bottom: 16px; display: grid; gap: 10px; }
.ch-form input {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 9px 12px;
}
.ch-form-acoes { display: flex; gap: 10px; }

.ch-grid { display: grid; grid-template-columns: minmax(280px, 380px) 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .ch-grid { grid-template-columns: 1fr; } }

.ch-col-lista { display: grid; gap: 8px; max-height: 74vh; overflow: auto; }
.ch-item {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--ink);
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 10px 12px; cursor: pointer;
}
.ch-item:hover { border-color: var(--line-strong); }
.ch-item.on { border-color: var(--brand); background: var(--chip); }
.ch-item-topo { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; }
.ch-item-titulo { font-weight: 650; margin-bottom: 2px; }
.ch-item-sub { font-size: var(--t1); }

.ch-det-cab { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.ch-det-titulo { font-weight: 700; margin-bottom: 3px; }
.ch-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }

.ch-conversa {
  display: grid; gap: 10px; max-height: 56vh; overflow: auto;
  padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md);
  background: var(--bg);
}
.ch-ev { max-width: 78%; }
.ch-ev-meta { font-size: var(--t1); margin-bottom: 3px; }
.ch-ev-texto {
  padding: 8px 12px; border-radius: var(--r-md); font-size: var(--t2);
  line-height: 1.5; white-space: pre-wrap; word-break: break-word;
}
/* enviada pelo Pulso/humano = à direita; recebida do motorista = à esquerda */
.ch-ev.env { justify-self: end; text-align: right; }
.ch-ev.env .ch-ev-texto { background: var(--chip); border: 1px solid var(--line-strong); text-align: left; }
.ch-ev.rec { justify-self: start; }
.ch-ev.rec .ch-ev-texto { background: var(--panel); border: 1px solid var(--line); }
/* raciocínio da IA: bloco tracejado, tom de bastidor (auditoria, não conversa) */
.ch-ev.pensa { max-width: 100%; justify-self: stretch; }
.ch-ev.pensa .ch-ev-texto {
  border: 1px dashed var(--line-strong); background: transparent;
  color: var(--muted); font-style: italic;
}
/* escalada chama atenção; eventos de sistema são notas de rodapé no centro */
.ch-ev.esc { max-width: 100%; justify-self: stretch; }
.ch-ev.esc .ch-ev-texto { background: var(--err-bg); color: var(--err); border: 1px solid color-mix(in oklch, var(--err) 35%, transparent); }
.ch-ev.sis { max-width: 100%; justify-self: center; text-align: center; }
.ch-ev.sis .ch-ev-meta { display: inline; }
.ch-ev.sis .ch-ev-texto { display: inline; padding: 0 6px; background: transparent; color: var(--muted); font-size: var(--t1); }

.ch-aviso {
  margin-bottom: 12px; padding: 8px 12px; border-radius: var(--r-md);
  background: var(--chip); border: 1px dashed var(--line-strong);
  color: var(--muted); font-size: var(--t2); line-height: 1.5;
}

.ch-envio-abrir { margin-top: 12px; }
.ch-envio { margin-top: 10px; display: grid; gap: 8px; }
.ch-envio-nota { font-size: var(--t1); line-height: 1.5; }
.ch-envio-linha { display: flex; gap: 8px; }
.ch-envio-linha input {
  flex: 1; font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 9px 12px; min-width: 0;
}

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