/* Painel inicial (templates/partials/home_content.html).
   Tudo sob .hp, com as cores em tokens. Fundo, borda e texto dos cartões vêm
   dos tokens globais de tema (--iaf-*, em styles.css): o painel fica com a
   mesma superfície dos cartões das outras telas em cada tema, e o tema que
   mudar lá muda aqui. Aqui só o que é do painel: realce, trilhos dos
   gráficos e as cores de nível. O destaque do plantel é escuro nos três
   temas, de propósito: é a peça de marca do painel. */

.hp {
  --hp-card: var(--iaf-superficie, #ffffff);
  --hp-borda: var(--iaf-borda, #dee2e6);
  --hp-texto: #0f172a;
  --hp-texto-2: #334155;
  --hp-texto-3: var(--iaf-texto-fraco, #64748b);
  --hp-fundo-suave: #f1f5f9;
  --hp-trilho: #e2e8f0;
  --hp-destaque: #0b63c4;
  --hp-destaque-suave: rgba(11, 99, 196, 0.22);
  --hp-sombra: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px -12px rgba(15, 23, 42, 0.14);
  --hp-alto: #dc2626;
  --hp-medio: #d97706;
  --hp-ok: #059669;
  --hp-erro: #64748b;
  --hp-mort: #e11d48;
  --hp-despesca: #0d9488;
  --hp-pronto: #d97706;
}

/* Escuro e azul são temas escuros: texto claro e cores de nível mais vivas,
   que no fundo escuro têm o contraste que as do claro perdem. */
html.dark .hp,
body.dark .hp,
html.azul .hp,
body.azul .hp {
  --hp-texto: #f1f5f9;
  --hp-texto-2: #cbd5e1;
  --hp-sombra: 0 1px 2px rgba(0, 0, 0, 0.3), 0 12px 30px -14px rgba(0, 0, 0, 0.6);
  --hp-alto: #f87171;
  --hp-medio: #fbbf24;
  --hp-ok: #34d399;
  --hp-erro: #94a3b8;
  --hp-mort: #fb7185;
  --hp-despesca: #2dd4bf;
  --hp-pronto: #fbbf24;
}

html.dark .hp,
body.dark .hp {
  --hp-fundo-suave: rgba(148, 163, 184, 0.08);
  --hp-trilho: rgba(148, 163, 184, 0.16);
  --hp-destaque: #4ea8ff;
  --hp-destaque-suave: rgba(78, 168, 255, 0.24);
}

/* No azul a superfície do cartão é a mesma do fundo da página (como nos
   .card do tema): a borda e a sombra é que separam. */
html.azul .hp,
body.azul .hp {
  --hp-fundo-suave: rgba(160, 196, 224, 0.1);
  --hp-trilho: rgba(160, 196, 224, 0.2);
  --hp-destaque: #7cc0ff;
  --hp-destaque-suave: rgba(124, 192, 255, 0.26);
}

.hp-wrap {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-top: 4px;
  color: var(--hp-texto);
  font-variant-numeric: tabular-nums;
}

/* ── Destaque do plantel ───────────────────────────────────────────── */
.hp-hero {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  padding: 26px 30px 24px;
  color: #ffffff;
  background:
    radial-gradient(900px 320px at 88% -10%, rgba(56, 189, 248, 0.32), transparent 60%),
    radial-gradient(700px 300px at -5% 110%, rgba(45, 212, 191, 0.22), transparent 60%),
    linear-gradient(135deg, #04152b 0%, #0a2f5c 48%, #0b4f74 100%);
  box-shadow: 0 24px 48px -24px rgba(4, 21, 43, 0.7);
  isolation: isolate;
}
.hp-hero-ondas {
  position: absolute;
  inset: auto 0 0 0;
  width: 100%;
  height: 46%;
  z-index: -1;
  pointer-events: none;
}
.hp-hero-ondas path:first-child { fill: rgba(56, 189, 248, 0.07); }
.hp-hero-ondas path:last-child { fill: rgba(45, 212, 191, 0.07); }

.hp-hero-topo {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.hp-hero-sobre {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7dd3fc;
}
.hp-hero-titulo {
  margin: 4px 0 2px;
  font-size: clamp(1.3rem, 2.1vw, 1.75rem);
  font-weight: 800;
  letter-spacing: -0.01em;
  color: #ffffff;
}
.hp-hero-data {
  font-size: 0.86rem;
  color: rgba(226, 238, 252, 0.72);
}
.hp-hero-data::first-letter { text-transform: uppercase; }

.hp-hero-status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(6px);
  font-size: 0.82rem;
  font-weight: 600;
  color: #e2eefc;
  text-decoration: none;
  transition: background 0.15s ease;
}
.hp-hero-status:hover { background: rgba(255, 255, 255, 0.14); color: #ffffff; }
.hp-hero-status-item { display: inline-flex; align-items: center; gap: 6px; }
.hp-hero-status-item::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.08);
}
.hp-hero-status-item--alto { color: #fca5a5; }
.hp-hero-status-item--medio { color: #fcd34d; }
.hp-hero-status-item--ok { color: #6ee7b7; }

.hp-hero-numeros {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  margin-top: 26px;
}
.hp-numero {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  padding: 0 20px;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}
.hp-numero:first-child { padding-left: 0; border-left: 0; }
.hp-numero-rotulo {
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(226, 238, 252, 0.66);
}
.hp-numero-valor {
  font-size: clamp(1.55rem, 2.3vw, 2.25rem);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: #ffffff;
  white-space: nowrap;
}
.hp-numero--principal .hp-numero-valor { font-size: clamp(1.9rem, 3vw, 2.9rem); }
.hp-numero-valor small {
  margin-left: 4px;
  font-size: 0.45em;
  font-weight: 600;
  letter-spacing: 0;
  color: rgba(226, 238, 252, 0.7);
}
.hp-numero-nota {
  font-size: 0.78rem;
  color: rgba(226, 238, 252, 0.62);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* Nota com dica (Estimada hoje, Curva hoje): o cursor avisa que ha explicacao. */
.hp-numero-nota[data-bs-toggle="tooltip"] { cursor: help; }

.hp-fases { margin-top: 24px; }
.hp-fases-titulo {
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(226, 238, 252, 0.6);
}
.hp-fases-barra {
  display: flex;
  gap: 3px;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}
.hp-fase { flex-basis: 0; min-width: 4px; }
.hp-fase--1 { background: #7dd3fc; }
.hp-fase--2 { background: #2dd4bf; }
.hp-fase--3 { background: #a78bfa; }
.hp-fase--4 { background: #38bdf8; }
.hp-fase--5 { background: #fbbf24; }
.hp-fase--6 { background: #f472b6; }
.hp-fases-legenda {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin-top: 10px;
}
.hp-fase-item {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.84rem;
  color: #e2eefc;
}
.hp-fase-item small { color: rgba(226, 238, 252, 0.6); font-size: 0.76rem; }
.hp-fase-cor {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  align-self: center;
}

/* ── Seções e cartões ──────────────────────────────────────────────── */
.hp-secao-cabeca,
.hp-card-cabeca {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.hp-secao-cabeca { margin-bottom: 12px; }
.hp-secao-titulo {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--hp-texto);
}
.hp-secao-sub,
.hp-card-sub {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--hp-texto-3);
}
.hp-ferramentas,
.hp-card-acoes {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.hp-hora { font-size: 0.76rem; color: var(--hp-texto-3); }
.hp-botao-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid var(--hp-borda);
  background: var(--hp-card);
  color: var(--hp-texto-2);
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}
.hp-botao-icone:hover { border-color: var(--hp-destaque); color: var(--hp-destaque); }
.hp-botao-icone:disabled { opacity: 0.5; }
.hp-botao-icone:disabled .bi { animation: hp-girar 0.9s linear infinite; }
@keyframes hp-girar { to { transform: rotate(360deg); } }

.hp-grade {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 20px;
}
.hp-span-8 { grid-column: span 8; }
.hp-span-4 { grid-column: span 4; }
.hp-span-3 { grid-column: span 3; }

.hp-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
  padding: 20px 22px;
  border-radius: 16px;
  background: var(--hp-card);
  border: 1px solid var(--hp-borda);
  box-shadow: var(--hp-sombra);
}
.hp-card--mini { gap: 12px; padding: 18px 20px; }
.hp-card-titulo {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--hp-texto);
}
.hp-card-titulo .bi {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 0.9rem;
  color: var(--hp-destaque);
  background: var(--hp-fundo-suave);
}
.hp-card--mini .hp-card-titulo { font-size: 0.9rem; }

.hp-grande {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  color: var(--hp-texto);
}
.hp-grande small {
  margin-left: 6px;
  font-size: 0.42em;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--hp-texto-3);
}

.hp-alternar {
  display: inline-flex;
  padding: 3px;
  border-radius: 10px;
  background: var(--hp-fundo-suave);
  border: 1px solid var(--hp-borda);
  flex-shrink: 0;
}
.hp-alternar button {
  border: 0;
  background: transparent;
  padding: 4px 10px;
  border-radius: 7px;
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--hp-texto-3);
}
.hp-alternar button.is-ativo {
  background: var(--hp-card);
  color: var(--hp-destaque);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.hp-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--hp-destaque);
  text-decoration: none;
  white-space: nowrap;
}
.hp-link:hover { text-decoration: underline; }

.hp-selo {
  display: inline-flex;
  align-items: center;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
  color: var(--hp-destaque);
  background: var(--hp-fundo-suave);
}
.hp-selo--alto { color: var(--hp-alto); background: color-mix(in srgb, var(--hp-alto) 12%, transparent); }
.hp-selo--medio { color: var(--hp-medio); background: color-mix(in srgb, var(--hp-medio) 14%, transparent); }
.hp-selo--ok { color: var(--hp-ok); background: color-mix(in srgb, var(--hp-ok) 12%, transparent); }
.hp-selo--erro { color: var(--hp-erro); }

/* ── Atenção hoje ──────────────────────────────────────────────────── */
.hp-alertas {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 16px;
}
.hp-alerta {
  --hp-nivel: var(--hp-borda);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 210px;
  padding: 18px 18px 16px;
  border-radius: 16px;
  border: 1px solid var(--hp-borda);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--hp-nivel) 9%, transparent) 0, transparent 110px),
    var(--hp-card);
  box-shadow: var(--hp-sombra);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.hp-alerta::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--hp-nivel);
}
.hp-alerta:hover { transform: translateY(-2px); }
.hp-alerta--alto { --hp-nivel: var(--hp-alto); }
.hp-alerta--medio { --hp-nivel: var(--hp-medio); }
.hp-alerta--ok { --hp-nivel: var(--hp-ok); }
.hp-alerta--erro { --hp-nivel: var(--hp-erro); }
.hp-alerta-topo {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hp-alerta-icone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  font-size: 0.95rem;
  color: var(--hp-nivel);
  background: color-mix(in srgb, var(--hp-nivel) 14%, transparent);
  flex-shrink: 0;
}
.hp-alerta-titulo {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--hp-texto-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hp-alerta-numero {
  margin-top: 6px;
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--hp-texto);
}
.hp-alerta--alto .hp-alerta-numero,
.hp-alerta--medio .hp-alerta-numero { color: var(--hp-nivel); }
.hp-alerta .hp-alerta-numero.is-zero { color: var(--hp-texto-3); }
.hp-alerta-rotulo {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--hp-texto-2);
}
.hp-alerta-linhas {
  list-style: none;
  margin: 4px 0 0;
  padding: 8px 0 0;
  border-top: 1px dashed var(--hp-borda);
  display: grid;
  gap: 3px;
}
.hp-alerta-linhas li {
  font-size: 0.76rem;
  line-height: 1.35;
  color: var(--hp-texto-3);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hp-alerta-link {
  margin-top: auto;
  padding-top: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--hp-destaque);
  text-decoration: none;
}
.hp-alerta-link:hover { text-decoration: underline; }
.hp-alerta.is-carregando span,
.hp-carregando-bloco span {
  display: block;
  border-radius: 6px;
  background: var(--hp-fundo-suave);
  animation: hp-pulso 1.2s ease-in-out infinite;
}
.hp-alerta.is-carregando span { height: 12px; }
.hp-alerta.is-carregando span:nth-child(1) { width: 55%; }
.hp-alerta.is-carregando span:nth-child(2) { width: 35%; height: 34px; margin-top: 10px; }
.hp-alerta.is-carregando span:nth-child(3) { width: 85%; margin-top: 10px; }
.hp-alerta.is-atualizando { opacity: 0.55; }
@keyframes hp-pulso { 50% { opacity: 0.45; } }

/* "Carregando": ícone girando, pontos que pulam e uma mensagem que troca
   enquanto a resposta não chega (home_painel.js::carregando). */
.hp-carregando {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--hp-texto-3);
}
.hp-carregando-giro {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--hp-trilho);
  border-top-color: var(--hp-destaque);
  animation: hp-girar 0.8s linear infinite;
}
.hp-carregando-texto { transition: opacity 0.25s ease; }
.hp-carregando-texto.is-trocando { opacity: 0; }
.hp-carregando-pontos { display: inline-flex; gap: 3px; margin-left: 2px; }
.hp-carregando-pontos i {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  animation: hp-ponto 1.2s ease-in-out infinite;
}
.hp-carregando-pontos i:nth-child(2) { animation-delay: 0.15s; }
.hp-carregando-pontos i:nth-child(3) { animation-delay: 0.3s; }
@keyframes hp-ponto {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}
/* No destaque escuro do plantel o texto é claro. */
.hp-hero-status .hp-carregando { color: rgba(255, 255, 255, 0.85); font-size: inherit; }
.hp-hero-status .hp-carregando-giro { border-color: rgba(255, 255, 255, 0.25); border-top-color: #ffffff; }
/* Sobre o esqueleto do gráfico, centrado. */
.hp-despescas { position: relative; }
.hp-carregando--sobre {
  position: absolute;
  inset: 0;
  z-index: 1;
  justify-content: center;
  pointer-events: none;
}
.hp-carregando--sobre > * { position: relative; }
.hp-carregando--sobre::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(340px, 90%);
  height: 44px;
  transform: translate(-50%, -50%);
  border-radius: 22px;
  background: var(--hp-card);
  box-shadow: var(--hp-sombra);
}
@media (prefers-reduced-motion: reduce) {
  .hp-carregando-giro,
  .hp-carregando-pontos i { animation-duration: 2.4s; }
}
.hp-aviso {
  grid-column: 1 / -1;
  padding: 14px 4px;
  font-size: 0.84rem;
  color: var(--hp-texto-3);
}

/* ── Trato ─────────────────────────────────────────────────────────── */
.hp-trato {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 8fr);
  gap: 24px;
  align-items: stretch;
}
.hp-trato-hoje { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.hp-trato-numeros { display: flex; flex-direction: column; gap: 2px; }
.hp-trato-de { font-size: 0.84rem; color: var(--hp-texto-3); }
/* Dia mostrado no cartão do trato (hoje ou o dia clicado no gráfico). */
.hp-trato-dia {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hp-destaque);
}
.hp-trato-voltar,
.hp-trato-ultimo {
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--hp-destaque);
  cursor: pointer;
}
.hp-trato-voltar { font-size: 0.72rem; font-weight: 600; text-transform: none; letter-spacing: 0; }
.hp-trato-voltar:hover,
.hp-trato-ultimo:hover { text-decoration: underline; }
.hp-trato-ultimo { text-align: left; font-size: 0.78rem; font-weight: 600; }
/* Dias do gráfico do trato: clicáveis; o escolhido fica marcado. */
[data-hp-grafico="trato"] .hp-col { cursor: pointer; border-radius: 8px; outline: none; }
[data-hp-grafico="trato"] .hp-col:hover .hp-col-area,
[data-hp-grafico="trato"] .hp-col:focus-visible .hp-col-area { background-color: var(--hp-fundo-suave); }
/* Sem dia escolhido, todas as colunas na cor normal; com um dia escolhido,
   ele fica na cor normal e os outros esmaecem. */
[data-hp-grafico="trato"] .hp-col { transition: opacity 0.2s ease; }
[data-hp-grafico="trato"].is-com-selecao .hp-col:not(.is-selecionado) { opacity: 0.35; }
[data-hp-grafico="trato"].is-com-selecao .hp-col:not(.is-selecionado):hover { opacity: 0.7; }
[data-hp-grafico="trato"] .hp-col.is-selecionado .hp-col-rotulo { font-weight: 700; color: var(--hp-texto); visibility: visible; }
.hp-card-cabeca-acoes { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.hp-trato-unidade { width: auto; max-width: 200px; }
.hp-progresso {
  height: 10px;
  border-radius: 999px;
  background: var(--hp-trilho);
  overflow: hidden;
}
.hp-progresso-barra {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--hp-destaque), #22d3ee);
  transition: width 0.6s ease;
}
.hp-progresso-texto { font-size: 0.78rem; font-weight: 600; color: var(--hp-texto-2); }
/* Abas Por ração / Por fase: barra na largura da lista, cada botão com metade. */
.hp-trato-abas { display: flex; align-self: stretch; width: 100%; margin-top: 4px; }
.hp-trato-abas button { flex: 1 1 0; }
.hp-racoes {
  list-style: none;
  margin: 4px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.hp-racoes li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  align-items: baseline;
  gap: 14px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--hp-fundo-suave);
  font-size: 0.8rem;
  color: var(--hp-texto-2);
}
.hp-racoes li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-racoes li strong,
.hp-racoes li em { min-width: 76px; text-align: right; white-space: nowrap; font-style: normal; }
.hp-racoes li strong { color: var(--hp-texto); }
.hp-racoes li em { color: var(--hp-texto-3); }
.hp-racoes li.hp-racoes-cabeca {
  padding-block: 0;
  background: none;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--hp-texto-3);
}
.hp-racoes li .hp-aderencia { min-width: 58px; text-align: right; white-space: nowrap; font-weight: 700; color: var(--hp-texto-3); }
.hp-racoes li .hp-aderencia.is-ok { color: var(--hp-ok); }
.hp-racoes li .hp-aderencia.is-fora { color: var(--hp-medio); }
.hp-racoes li.hp-racoes-cabeca em,
.hp-racoes li.hp-racoes-cabeca strong,
.hp-racoes li.hp-racoes-cabeca .hp-aderencia { color: inherit; font-weight: inherit; }
.hp-racoes li.hp-vazio-linha { display: block; }
.hp-vazio-linha { color: var(--hp-texto-3); }

.hp-grafico { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
/* Os gráficos crescem até o pé do cartão quando o vizinho da linha é mais alto. */
.hp-trato { flex: 1; }
.hp-grafico .hp-colunas,
.hp-colunas--mort { flex: 1; height: auto; min-height: 190px; }
.hp-legenda {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 16px;
  font-size: 0.76rem;
  color: var(--hp-texto-3);
}
.hp-legenda span { display: inline-flex; align-items: center; gap: 6px; }
.hp-legenda-resumo { margin-left: auto; font-weight: 600; color: var(--hp-texto-2); }
.hp-cor { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.hp-cor--sugerido { background: var(--hp-destaque-suave); }
.hp-cor--lancado { background: var(--hp-destaque); }

/* Colunas (trato, mortalidade, despescas): HTML puro, texto nítido em qualquer largura */
.hp-colunas {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 6px;
  height: 190px;
  padding-top: 18px;
}
.hp-col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.hp-col-area {
  position: relative;
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  border-bottom: 1px solid var(--hp-trilho);
  background-image: linear-gradient(to top, var(--hp-trilho) 1px, transparent 1px);
  background-size: 100% 33.33%;
}
.hp-barra {
  position: relative;
  width: 100%;
  max-width: 34px;
  min-height: 2px;
  border-radius: 6px 6px 2px 2px;
  background: var(--hp-destaque);
  transition: height 0.5s ease;
}
.hp-colunas--pares .hp-barra { max-width: 16px; }
.hp-barra--sugerido { background: var(--hp-destaque-suave); }
.hp-barra--mort { background: var(--hp-mort); max-width: 22px; }
.hp-barra--despesca { background: linear-gradient(180deg, #2dd4bf, var(--hp-despesca)); max-width: 56px; }
.hp-barra--pronto { background: linear-gradient(180deg, #fbbf24, var(--hp-pronto)); max-width: 56px; }
.hp-barra--depois { background: var(--hp-trilho); max-width: 56px; }
.hp-barra-valor {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding-bottom: 3px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--hp-texto-2);
  white-space: nowrap;
}
.hp-col-rotulo {
  font-size: 0.7rem;
  color: var(--hp-texto-3);
  white-space: nowrap;
}
.hp-col-sub {
  margin-top: -4px;
  font-size: 0.66rem;
  color: var(--hp-texto-3);
  opacity: 0.8;
  white-space: nowrap;
}
.hp-col.is-destaque .hp-col-rotulo { font-weight: 700; color: var(--hp-pronto); }
.hp-col-rotulo.is-oculto { visibility: hidden; }
.hp-grafico-vazio {
  position: absolute;
  inset: 18px 0 26px 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--hp-texto-3);
  pointer-events: none;
}
.hp-grafico-vazio span {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--hp-card);
  border: 1px solid var(--hp-borda);
}

/* ── Ocupação ──────────────────────────────────────────────────────── */
.hp-ocupacao {
  display: grid;
  grid-template-columns: 132px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}
.hp-rosca { position: relative; width: 132px; height: 132px; }
.hp-rosca svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.hp-rosca circle { fill: none; stroke-width: 13; }
.hp-rosca-trilho { stroke: var(--hp-trilho); }
.hp-rosca-valor {
  stroke: var(--hp-destaque);
  stroke-linecap: round;
  stroke-dasharray: 0 400;
  transition: stroke-dasharray 0.8s ease;
}
.hp-rosca-centro {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hp-rosca-centro strong { font-size: 1.6rem; font-weight: 800; color: var(--hp-texto); line-height: 1; }
.hp-rosca-centro small { margin-top: 4px; font-size: 0.72rem; color: var(--hp-texto-3); }

.hp-dados {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin: 0;
}
.hp-dados--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
[data-hp-desempenho] [hidden] { display: none; }
.hp-dados div { min-width: 0; }
.hp-dados dt {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--hp-texto-3);
}
.hp-dados dd {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--hp-texto);
  white-space: nowrap;
}
.hp-dados dd small { font-size: 0.68rem; font-weight: 600; color: var(--hp-texto-3); }
.hp-ocupacao .hp-dados { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.hp-linhas { display: grid; gap: 8px; padding-top: 14px; border-top: 1px solid var(--hp-borda); }
.hp-linhas-titulo {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hp-texto-3);
}
.hp-linha {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 10px;
  font-size: 0.78rem;
  color: var(--hp-texto-2);
}
.hp-linha-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-linha-num { font-weight: 700; color: var(--hp-texto); }
.hp-linha-trilho {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: var(--hp-trilho);
  overflow: hidden;
}
.hp-linha-trilho span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--hp-destaque);
}
.hp-mais { font-size: 0.74rem; color: var(--hp-texto-3); }

/* ── Despescas previstas ───────────────────────────────────────────── */
.hp-despescas { display: flex; flex-direction: column; gap: 14px; }
.hp-despescas .hp-colunas { height: 210px; gap: 10px; padding-top: 22px; }
.hp-despescas-resumo {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.hp-despescas-resumo div {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--hp-fundo-suave);
}
.hp-despescas-resumo dt { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--hp-texto-3); }
.hp-despescas-resumo dd { margin: 2px 0 0; font-size: 1.05rem; font-weight: 800; color: var(--hp-texto); }
.hp-despescas-resumo dd small { font-size: 0.7rem; font-weight: 600; color: var(--hp-texto-3); }
.hp-despescas-resumo .is-pronto dd { color: var(--hp-pronto); }
.hp-despescas-nota { margin: 0; font-size: 0.75rem; color: var(--hp-texto-3); }
.hp-despescas.is-atualizando { opacity: 0.55; transition: opacity 0.2s ease; }
/* Coluna empilhada: em cima o peixe ainda em fase anterior (listrado), embaixo o
   que já está na fase final. As partes dividem a altura pela tonelada. */
.hp-pilha {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 56px;
  min-height: 2px;
  transition: height 0.5s ease;
}
.hp-pilha .hp-barra { max-width: none; min-height: 0; flex-basis: 0; border-radius: 0; }
.hp-pilha .hp-barra:first-of-type { border-radius: 6px 6px 0 0; }
.hp-pilha .hp-barra:last-of-type { border-bottom-left-radius: 2px; border-bottom-right-radius: 2px; }
.hp-barra--anteriores {
  background: repeating-linear-gradient(135deg,
    color-mix(in srgb, var(--hp-despesca) 45%, transparent) 0 5px,
    color-mix(in srgb, var(--hp-despesca) 18%, transparent) 5px 10px);
}
.hp-despescas-legenda { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.72rem; color: var(--hp-texto-3); }
.hp-despescas-legenda span { display: inline-flex; align-items: center; gap: 6px; }
.hp-legenda-cor { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.hp-peso-despesca {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 0.74rem;
  color: var(--hp-texto-3);
}
.hp-peso-despesca input {
  width: 76px;
  height: 32px;
  padding: 0 8px;
  border-radius: 9px;
  border: 1px solid var(--hp-borda);
  background: var(--hp-card);
  color: var(--hp-texto);
  font-size: 0.82rem;
  font-weight: 700;
  text-align: right;
}
.hp-peso-despesca input:focus { outline: none; border-color: var(--hp-destaque); box-shadow: 0 0 0 3px var(--hp-destaque-suave); }
.hp-despescas-erro { margin: -4px 0 8px; font-size: 0.76rem; font-weight: 600; color: var(--hp-alto); }
.hp-carregando-bloco {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 210px;
}
.hp-carregando-bloco span { flex: 1; }
.hp-carregando-bloco span:nth-child(odd) { height: 45%; }
.hp-carregando-bloco span:nth-child(even) { height: 75%; }

/* ── Mortalidade ───────────────────────────────────────────────────── */
.hp-mort-topo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.hp-colunas--mort { gap: 3px; }

/* ── Apoio ─────────────────────────────────────────────────────────── */
.hp-rodape { margin: 0; font-size: 0.76rem; color: var(--hp-texto-3); }
.hp-vazio {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  border-radius: 12px;
  border: 1px dashed var(--hp-borda);
  font-size: 0.82rem;
  color: var(--hp-texto-3);
}
.hp-vazio .bi { font-size: 1.3rem; color: var(--hp-texto-3); opacity: 0.8; }
.hp-vazio--ok .bi { color: var(--hp-ok); opacity: 1; }
.hp-vazio-acao { display: inline-block; margin-top: 6px; font-weight: 700; color: var(--hp-destaque); text-decoration: none; }
.hp-vazio-acao:hover { text-decoration: underline; }
/* Parâmetros ambientais: nome, valor e o dia da última medição. */
.hp-parametros { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.hp-parametros li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 52px;
  align-items: baseline;
  gap: 8px;
  padding: 4px 0;
  border-bottom: 1px solid var(--hp-borda);
}
.hp-parametros li:last-child { border-bottom: 0; }
.hp-parametro-nome { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.78rem; color: var(--hp-texto-2); }
.hp-parametro-valor { font-size: 0.95rem; font-weight: 800; color: var(--hp-texto); white-space: nowrap; }
.hp-parametro-valor small { font-size: 0.66rem; font-weight: 600; color: var(--hp-texto-3); }
.hp-parametro-data { justify-self: end; font-size: 0.7rem; font-weight: 600; color: var(--hp-texto-3); }
.hp-parametro-data.is-hoje { color: var(--hp-ok); }
.hp-parametro-data.is-antiga { color: var(--hp-medio); }
.hp-tickets { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hp-tickets li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--hp-fundo-suave);
  border-left: 3px solid var(--hp-medio);
}
.hp-tickets li.is-atrasado { border-left-color: var(--hp-alto); }
.hp-ticket-texto { display: flex; flex-direction: column; min-width: 0; }
.hp-ticket-texto strong,
.hp-ticket-texto small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hp-ticket-texto strong { font-size: 0.8rem; color: var(--hp-texto); }
.hp-ticket-texto small { font-size: 0.72rem; color: var(--hp-texto-3); }
.hp-ticket-prazo { font-size: 0.74rem; font-weight: 700; color: var(--hp-texto-2); white-space: nowrap; }
.hp-tickets li.is-atrasado .hp-ticket-prazo { color: var(--hp-alto); }
/* Grupo de tickets (familia): a linha inteira e o botao que abre o modal. */
.hp-tickets li.hp-tickets-grupo { padding: 0; }
.hp-ticket-grupo {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}
.hp-ticket-grupo:hover,
.hp-ticket-grupo:focus-visible { background: var(--hp-fundo-hover, rgba(148, 163, 184, 0.12)); outline: none; }
.hp-ticket-total { font-size: 1rem; font-weight: 800; color: var(--hp-texto); white-space: nowrap; }
.hp-tickets li.is-atrasado .hp-ticket-texto small { color: var(--hp-alto); }
.hp-tickets-tabela th { font-size: 0.74rem; white-space: nowrap; }
.hp-tickets-tabela td { font-size: 0.8rem; }
.hp-ticket-situacao { font-weight: 700; color: var(--hp-ok); }
.hp-ticket-situacao.is-atrasado { color: var(--hp-alto); }

/* ── Larguras ──────────────────────────────────────────────────────── */
@media (max-width: 1399.98px) {
  .hp-hero-numeros { grid-template-columns: repeat(3, minmax(0, 1fr)); row-gap: 20px; }
  .hp-numero:nth-child(4) { padding-left: 0; border-left: 0; }
}
/* Tablet: 3 cartões em cima e 2 embaixo (ou 3 + 1 sem o financeiro). Só nesta
   faixa: os vãos de 2 e 3 colunas criariam colunas a mais no celular. */
@media (min-width: 768px) and (max-width: 1399.98px) {
  .hp-alertas { grid-auto-flow: row; grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .hp-alertas > * { grid-column: span 2; }
  .hp-alertas > :nth-child(4):nth-last-child(2),
  .hp-alertas > :nth-child(5):last-child { grid-column: span 3; }
  .hp-alertas > :nth-child(4):last-child { grid-column: span 6; }
}
@media (max-width: 1199.98px) {
  .hp-span-8,
  .hp-span-4 { grid-column: span 12; }
  .hp-span-3 { grid-column: span 6; }
}
@media (max-width: 767.98px) {
  .hp-hero { padding: 20px 18px; border-radius: 16px; }
  .hp-hero-numeros { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hp-numero { padding: 0 0 0 14px; }
  .hp-numero:nth-child(odd) { padding-left: 0; border-left: 0; }
  .hp-numero:nth-child(4) { padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, 0.12); }
  .hp-numero--principal { grid-column: 1 / -1; }
  .hp-numero--principal + .hp-numero { padding-left: 0; border-left: 0; }
  .hp-numero--principal ~ .hp-numero:nth-child(odd) { padding-left: 14px; border-left: 1px solid rgba(255, 255, 255, 0.12); }
  .hp-numero--principal ~ .hp-numero:nth-child(even) { padding-left: 0; border-left: 0; }
  .hp-alertas { grid-auto-flow: row; grid-template-columns: 1fr; }
  .hp-alerta { min-height: 0; }
  .hp-span-3 { grid-column: span 12; }
  .hp-trato { grid-template-columns: 1fr; }
  .hp-card { padding: 18px 16px; }
  .hp-ocupacao { grid-template-columns: 110px minmax(0, 1fr); }
  .hp-rosca { width: 110px; height: 110px; }
  .hp-despescas-resumo { grid-template-columns: 1fr 1fr; }
  /* Doze meses não cabem na largura do celular: as colunas rolam de lado. */
  .hp-colunas-rolagem { overflow-x: auto; }
  .hp-despescas .hp-colunas { gap: 4px; min-width: 620px; }
  .hp-peso-despesca span { display: none; }
}
