/* ============================================================
   app.css · janela da plataforma Hify (componente compartilhado)
   Todas as telas do produto na página usam estas peças.
   Quebras por container query: a mesma janela serve no hero,
   no tour, em recortes e no celular.
   ============================================================ */

.app {
  /* Linhas internas sempre neutras, mesmo sobre faixa laranja */
  --line: var(--line-n);
  --line-2: var(--line-2-n);
  --app-side-w: 184px;
  --app-top-h: 44px;
  --app-pad: 16px;
  container: app / inline-size;
  position: relative;
  margin: 0;
  display: flex; flex-direction: column;
  min-width: 0;
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: var(--r-float);
  overflow: hidden;
  font-size: var(--fs-meta);
  line-height: 1.45;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Barra superior ---------- */
.app-top {
  display: flex; align-items: center; gap: 12px;
  height: var(--app-top-h); padding: 0 12px 0 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.app-mark { width: 14px; height: 14px; flex: none; fill: var(--orange); }
.app-crumb { display: flex; align-items: center; gap: 8px; min-width: 0; overflow: hidden; color: var(--ink-3); }
.app-crumb b { font-weight: 700; color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.app-crumb .sep { color: var(--line-3); }
.app-env {
  flex: none; padding: 1px 8px; border: 1px solid var(--line-2); border-radius: var(--r-pill);
  color: var(--ink-2); font-family: var(--mono);
}
.app-search {
  margin-left: auto; flex: 0 1 240px; min-width: 0;
  display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 10px;
  border: 1px solid var(--line); border-radius: var(--r-control); background: var(--paper-2);
  color: var(--ink-3); overflow: hidden;
}
.app-search::before { content: ""; width: 8px; height: 8px; flex: none; border: 1.5px solid var(--line-3); border-radius: 50%; }
.app-live { display: inline-flex; align-items: center; gap: 8px; color: var(--ink-2); font-family: var(--mono); }
.app-live::before { content: ""; width: 6px; height: 6px; background: var(--orange); }

/* ---------- Corpo: barra lateral + área principal ---------- */
.app-body { display: grid; grid-template-columns: var(--app-side-w) minmax(0, 1fr); flex: 1; min-height: 0; }
.app-side {
  display: flex; flex-direction: column; gap: 2px;
  padding: 12px 8px; border-right: 1px solid var(--line); background: var(--paper-2);
}
.app-side-k { padding: 10px 10px 6px; color: var(--ink-3); }
.app-nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  min-height: 32px; padding: 0 10px;
  border: 0; border-radius: var(--r-control); background: none;
  font: inherit; font-size: var(--fs-meta); text-align: left; color: var(--ink-2);
}
.app-nav-item::before { content: ""; width: 6px; height: 6px; flex: none; background: var(--line-2); }
.app-nav-item .n { margin-left: auto; font-family: var(--mono); color: var(--ink-3); }
.app-nav-item[aria-current="page"],
.app-nav-item[aria-selected="true"] { background: var(--paper); color: var(--ink); font-weight: 700; box-shadow: inset 0 0 0 1px var(--line); }
.app-nav-item[aria-current="page"]::before,
.app-nav-item[aria-selected="true"]::before { background: var(--orange); }

.app-main { min-width: 0; padding: var(--app-pad); display: grid; gap: var(--app-pad); align-content: start; }
.app-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.app-title { font-size: var(--fs-body); line-height: 1.3; font-weight: 700; letter-spacing: -0.01em; }
.app-sub { color: var(--ink-3); }

/* Legenda obrigatória de toda janela.
   Quando as duas partes não cabem numa linha, a segunda desce inteira e alinha à esquerda
   (em vez de cada uma quebrar em duas linhas lado a lado). */
.app-cap {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px;
  padding: 8px 14px; border-top: 1px solid var(--line);
  background: var(--paper-2); color: var(--ink-3);
}

/* ---------- Painéis internos ---------- */
.panel { min-width: 0; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--paper); }
.panel-h {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 12px; border-bottom: 1px solid var(--line); color: var(--ink-2);
}
.panel-h b { color: var(--ink); font-weight: 700; }
.panel-b { padding: 12px; }

/* ---------- KPIs ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); border: 1px solid var(--line); border-radius: var(--r-control); }
.kpi { display: grid; gap: 4px; align-content: start; padding: 12px; min-width: 0; }
.kpi + .kpi { border-left: 1px solid var(--line); }
.kpi-k { color: var(--ink-3); }
.kpi-v { font-size: var(--fs-body); font-weight: 700; line-height: 1.2; letter-spacing: -0.01em; }
.kpi-v small { font-size: var(--fs-meta); font-weight: 400; color: var(--ink-3); letter-spacing: 0; }
.kpi-note { color: var(--ink-3); }

/* ---------- Tabela ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl caption { text-align: left; }
.tbl th {
  padding: 8px 10px; text-align: left; font-weight: 400; color: var(--ink-3);
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }
.tbl .id { font-family: var(--mono); color: var(--ink-3); white-space: nowrap; }
.tbl .route { font-family: var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }
.tbl tr[data-hot] td { background: var(--orange-50); }

/* ---------- Severidade: quadrados + texto (nunca só cor) ---------- */
.sev { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.sev > i { display: block; width: 5px; height: 10px; background: var(--line-2); }
.sev > i + i { margin-left: -4px; }
.sev-bars { display: inline-flex; gap: 2px; }
.sev-bars i { width: 4px; height: 10px; margin: 0; background: var(--line-2); }
.sev[data-sev="critica"] .sev-bars i,
.sev[data-sev="alta"] .sev-bars i:nth-child(-n + 3),
.sev[data-sev="media"] .sev-bars i:nth-child(-n + 2),
.sev[data-sev="baixa"] .sev-bars i:nth-child(-n + 1) { background: var(--orange); }
.sev[data-sev="critica"] { font-weight: 700; }

/* ---------- Estado do achado ---------- */
.state {
  display: inline-flex; align-items: center; gap: 6px; flex: none;
  padding: 1px 8px; border: 1px solid var(--line-2); border-radius: var(--r-pill);
  color: var(--ink-2); white-space: nowrap; background: var(--paper);
}
.state::before { content: ""; width: 5px; height: 5px; flex: none; background: var(--line-3); }
.state[data-state="observado"] { border-style: dashed; color: var(--ink-3); }
.state[data-state="validado"] { border-color: var(--ink); color: var(--ink); }
.state[data-state="validado"]::before { background: var(--ink); }
.state[data-state="correcao"],
.state[data-state="reteste"] { border-color: var(--orange-300); color: var(--orange-700); }
.state[data-state="correcao"]::before,
.state[data-state="reteste"]::before { background: var(--orange); }
.state[data-state="corrigido"] { background: var(--paper-2); color: var(--ink-2); }
.state[data-state="corrigido"]::before { background: var(--ink); }
.state[data-state="bloqueado"] { border-style: dashed; color: var(--ink-3); background: var(--paper-2); }

/* Selo de validação por especialista */
.verified { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); white-space: nowrap; }
.verified::before {
  content: ""; width: 10px; height: 10px; flex: none;
  background: var(--orange);
  clip-path: polygon(0 50%, 20% 30%, 40% 50%, 80% 10%, 100% 30%, 40% 90%);
}

/* ---------- Botões dentro do app ---------- */
.app-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 30px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--r-control); background: var(--paper);
  font: inherit; font-size: var(--fs-meta); font-weight: 700; color: var(--ink);
  white-space: nowrap; cursor: pointer;
  transition: transform var(--dur-micro) var(--ease-out-cubic), background-color var(--dur-micro) var(--ease-out-cubic);
}
.app-btn:active { transform: scale(0.97); }
.app-btn-primary { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.app-btn-ink { background: var(--ink); border-color: var(--ink); color: var(--paper); }
@media (hover: hover) and (pointer: fine) {
  .app-btn:hover { background: var(--paper-2); }
  .app-btn-primary:hover { background: color-mix(in oklch, var(--orange), var(--ink) 6%); }
  .app-btn-ink:hover { background: color-mix(in oklch, var(--ink), var(--paper) 8%); }
}
span.app-btn { cursor: default; }
span.app-btn:active { transform: none; }

/* Chips de filtro (reais, filtram) */
.chipset { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-f {
  display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 10px;
  border: 1px solid var(--line-2); border-radius: var(--r-pill); background: var(--paper);
  font: inherit; font-size: var(--fs-meta); color: var(--ink-2); cursor: pointer;
  transition: transform var(--dur-micro) var(--ease-out-cubic);
}
.chip-f:active { transform: scale(0.97); }
.chip-f[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--paper); }
/* Contagem: ink-3 sobre papel passa AA (sem opacidade); no chip ativo (fundo ink) herda o papel */
.chip-f .n { font-family: var(--mono); color: var(--ink-3); }
.chip-f[aria-pressed="true"] .n { color: inherit; opacity: 0.8; }

/* Tag técnica (rota, CWE, ID) */
.tag-m { display: inline-block; padding: 0 6px; border: 1px solid var(--line); border-radius: 4px; background: var(--paper-2); font-family: var(--mono); color: var(--ink-2); white-space: nowrap; }

/* Barras de mini-gráfico (sem canvas) */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 72px; }
.bars span { flex: 1; min-width: 4px; background: var(--line-2); }
.bars span[data-hot] { background: var(--orange); }

/* Log técnico em mono */
.app-log { font-family: var(--mono); font-size: var(--fs-meta); line-height: 1.5; }
.app-log li { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: baseline; padding: 6px 12px; border-bottom: 1px dashed var(--line); }
.app-log .who { color: var(--ink-3); }

/* ---------- Container queries ---------- */
@container app (max-width: 820px) {
  .app-body { grid-template-columns: minmax(0, 1fr); }
  .app-side { display: none; }
  .app-search { display: none; }
}
@container app (max-width: 520px) {
  .app { --app-pad: 12px; }
  /* O ambiente (homologação) fica sempre visível; some o começo do caminho */
  .app-crumb > :not(:last-child) { display: none; }
  .kpi + .kpi { border-left: 0; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:nth-child(n + 3) { border-top: 1px solid var(--line); }
  .kpis .kpi:nth-child(even) { border-left: 1px solid var(--line); }
  /* Tabelas viram cartões: cada <td> leva data-k com o nome da coluna */
  .tbl-stack thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .tbl-stack, .tbl-stack tbody, .tbl-stack tr, .tbl-stack td { display: block; width: 100%; }
  .tbl-stack tr { padding: 10px 0; border-bottom: 1px solid var(--line); }
  .tbl-stack tr:last-child { border-bottom: 0; }
  .tbl-stack td { display: flex; justify-content: space-between; gap: 12px; padding: 3px 10px; border: 0; text-align: right; }
  .tbl-stack td::before { content: attr(data-k); color: var(--ink-3); text-align: left; }
  .tbl-stack td[data-k=""]::before, .tbl-stack td:not([data-k])::before { content: none; }
  .tbl-stack .num { text-align: right; }
}

/* ---------- Gráficos compartilhados (hero e tour) ----------
   .lc: linha de uma série sobre SVG esticado (viewBox 0 0 100 100); pontos em HTML por --x (0..1) e --v (0..100).
   .hbars: barras horizontais finas, escala 0..100 em --v. */
.lc { --plot-h: 132px; display: flex; flex-direction: column; flex: 1; min-height: 0; padding-left: 26px; padding-right: 6px; }
.lc-plot { position: relative; flex: 1 0 var(--plot-h); min-height: 56px; margin-block: 6px; }
.lc-grid { position: absolute; left: 0; right: 0; top: calc(var(--y) * 100%); height: 0; border-top: 1px solid var(--line); }
.lc-grid i { position: absolute; right: calc(100% + 6px); top: -0.72em; font-style: normal; color: var(--ink-3); font-family: var(--mono); font-size: 11px; }
/* Linha laranja com gradiente e brilho; os gradientes (#lc-stroke, #lc-fill, #lc-shine) são injetados pelo script.js.
   Sem JS, a linha fica laranja sólida */
.lc-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 0 5px oklch(0.6559 0.2328 34.52 / 0.45)); }
.lc-area { fill: url(#lc-fill) var(--orange-50); }
.lc-path, .lc-shine { fill: none; stroke-width: 2px; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.lc-path { stroke: url(#lc-stroke) var(--orange); }
.lc-shine { stroke: url(#lc-shine) transparent; stroke-width: 9px; }
/* Pontos: alvo de 20px, marca de 8px; dica no hover (a tabela sr-only é a versão acessível) */
.lc-dot {
  position: absolute; left: calc(var(--x) * 100%); top: calc((1 - var(--v) / 100) * 100%);
  width: 20px; height: 20px; translate: -50% -50%;
  display: grid; place-items: center;
}
/* Só o ponto final aparece; os do meio surgem no hover */
.lc-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--paper); box-shadow: 0 0 0 2px var(--orange); opacity: 0; transition: opacity var(--dur-ui) var(--ease-out-cubic); }
.lc-dot[data-end]::before { width: 10px; height: 10px; background: var(--orange); box-shadow: 0 0 0 2px var(--paper), 0 0 10px 2px oklch(0.6559 0.2328 34.52 / 0.55); opacity: 1; }
.lc-dot[data-end]::after { z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  .lc-dot[data-end]::before { animation: lc-pulse 2.4s var(--ease-out-cubic) infinite; }
}
@keyframes lc-pulse {
  0% { box-shadow: 0 0 0 2px var(--paper), 0 0 10px 2px oklch(0.6559 0.2328 34.52 / 0.55), 0 0 0 2px oklch(0.6559 0.2328 34.52 / 0.5); }
  70%, 100% { box-shadow: 0 0 0 2px var(--paper), 0 0 10px 2px oklch(0.6559 0.2328 34.52 / 0.55), 0 0 0 12px oklch(0.6559 0.2328 34.52 / 0); }
}
.lc-dot::after {
  content: attr(data-tip); position: absolute; bottom: calc(100% + 4px); left: 50%;
  padding: 3px 8px; border-radius: var(--r-control); background: var(--ink); color: var(--paper); white-space: nowrap;
  opacity: 0; transform: translate(-50%, 4px); pointer-events: none;
  transition: opacity var(--dur-ui) var(--ease-out-cubic), transform var(--dur-ui) var(--ease-out-cubic);
}
.lc-dot[data-end]::after { left: auto; right: -4px; transform: translateY(4px); }
@media (hover: hover) and (pointer: fine) {
  .lc-dot:hover::before { opacity: 1; }
  .lc-dot:hover::after { opacity: 1; transform: translate(-50%, 0); }
  .lc-dot[data-end]:hover::after { transform: none; }
}
/* Rótulo direto só no primeiro e no último ponto */
.lc-lbl {
  position: absolute; left: calc(var(--x) * 100%); top: calc((1 - var(--v) / 100) * 100%);
  transform: translate(4px, calc(-100% - 6px)); font-family: var(--mono); font-size: 11px; color: var(--ink-2); white-space: nowrap; pointer-events: none;
}
.lc-lbl[data-end] { transform: translate(calc(-100% - 2px), calc(-100% - 8px)); color: var(--ink); }
/* Marco da Hify (.lc-break): faixa cinza antes, linha laranja no mês em que a Hify entrou, queda forte e descida contínua */
.lc-before { position: absolute; left: 0; top: 0; bottom: 0; width: calc(var(--x) * 100%); background: var(--paper-2); }
.lc-before i, .lc-event i { position: absolute; bottom: 5px; font-style: normal; font-size: 11px; line-height: 1.2; white-space: nowrap; }
.lc-before i { left: 6px; right: 8px; white-space: normal; color: var(--ink-3); }
.lc-event { position: absolute; left: calc(var(--x) * 100%); top: -6px; bottom: 0; width: 2px; translate: -1px 0; background: var(--orange); pointer-events: none; }
.lc-event i { left: 8px; color: var(--orange-700); }
.lc-event[data-top] i { bottom: auto; top: 6px; }
.lc-path[data-pre] { stroke: url(#lc-stroke) var(--orange-300); }
.lc-dot[data-pre]::before { box-shadow: 0 0 0 2px var(--orange-300); }
.lc-lbl[data-drop] { color: var(--orange-700); }
.lc-x { display: flex; justify-content: space-between; margin-inline: -8px; color: var(--ink-3); font-family: var(--mono); font-size: 11px; }
/* Entrada: a linha se desenha da esquerda para a direita quando o gráfico aparece (data-in vem do script.js).
   Sem JS, com movimento reduzido ou na impressão, o gráfico já aparece pronto */
@media screen and (prefers-reduced-motion: no-preference) {
  .lc-svg { clip-path: inset(-14px); transition: clip-path 1.6s var(--ease-out-cubic); }
  html.js .lc:not([data-in]) .lc-svg { clip-path: inset(-14px 100% -14px -14px); }
  .lc-dot[data-end], .lc-lbl { transition: opacity 500ms var(--ease-out-cubic) 1.2s; }
  html.js .lc:not([data-in]) :is(.lc-dot[data-end], .lc-lbl) { opacity: 0; }
}

.hbars { display: grid; align-content: start; gap: 12px; }
.hbars li { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; row-gap: 5px; column-gap: 8px; }
.hbar-k { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-v { font-family: var(--mono); color: var(--ink); }
/* Barras em traços (3px aceso, 2px vão): trilho apagado em cinza claro, valor aceso por cima */
.hbar { --tick: repeating-linear-gradient(90deg, #000 0 3px, transparent 3px 5px); grid-column: 1 / -1; display: block; height: 8px; background: repeating-linear-gradient(90deg, var(--line) 0 3px, transparent 3px 5px); }
.hbar i {
  display: block; height: 100%; width: calc(var(--v) * 1%); width: max(5px, round(nearest, calc(var(--v) * 1%), 5px)); background: var(--ink);
  -webkit-mask: var(--tick); mask: var(--tick);
}
.hbars li[data-top] .hbar i { background: var(--orange); }
.hbars li[data-top] .hbar-k { color: var(--ink); font-weight: 700; }


