/* AIH · críticas do SIHD2 antes do envio: janela animada de análise (.sa), lista de críticas com orientação (.sc),
   aprendizado com o PDF da secretaria (.sr) e base do CNES (.sb). Sem media query de largura (escala mc-scaled). */

/* ---------- janela animada de análise ---------- */
.aih-lotes.sa .sa-topo {
    --cor: var(--p-blue); --cor-soft: var(--p-blue-soft);
    display: flex; align-items: center; gap: 18px; padding: 14px 16px; border-radius: 16px;
    background: var(--cor-soft); border: 1px solid var(--p-blue-line-soft);
}
.aih-lotes.sa .sa-topo.ok { --cor: var(--p-green); --cor-soft: var(--p-green-soft); }
.aih-lotes.sa .sa-topo.risco { --cor: var(--p-orange); --cor-soft: var(--p-orange-soft); }
.aih-lotes.sa .sa-topo.erro { --cor: var(--p-red); --cor-soft: var(--p-red-soft); }
.aih-lotes .sa-radar { position: relative; width: 64px; height: 64px; flex: none; display: grid; place-items: center; color: var(--cor); }
.aih-lotes .sa-radar > i { position: relative; font-size: 30px; z-index: 1; }
.aih-lotes .sa-anel {
    position: absolute; inset: 14px; border-radius: 50%; border: 2px solid var(--cor); opacity: 0;
}
.aih-lotes .sa-topo.rodando .sa-anel { animation: saAnel 2.1s ease-out infinite; }
.aih-lotes .sa-topo.rodando .sa-anel.b { animation-delay: .7s; }
.aih-lotes .sa-topo.rodando .sa-anel.c { animation-delay: 1.4s; }
.aih-lotes .sa-topo.rodando .sa-radar > i { animation: saPulso 1.2s ease-in-out infinite; }
.aih-lotes .sa-topo:not(.rodando) .sa-anel { opacity: .18; inset: 8px; }
@keyframes saAnel { 0% { transform: scale(.55); opacity: .75; } 100% { transform: scale(1.7); opacity: 0; } }
@keyframes saPulso { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.12); } }
.aih-lotes .sa-topo-tit { font-size: 1rem; font-weight: 800; color: var(--p-ink); letter-spacing: -.2px; }
.aih-lotes .sa-topo-sub { font-size: .76rem; font-weight: 600; color: var(--p-muted); margin-top: 2px; }

.aih-lotes .sa-barra { height: 8px; border-radius: 99px; background: var(--p-blue-line-soft); overflow: hidden; margin: 14px 0 12px; }
.aih-lotes .sa-barra > i {
    display: block; height: 100%; border-radius: 99px; transition: width .35s var(--p-ease, ease);
    background: linear-gradient(90deg, var(--p-blue), var(--p-blue-light, var(--p-blue)));
    background-size: 28px 28px;
}
.aih-lotes .sa-topo.rodando ~ .sa-barra > i {
    background-image: linear-gradient(135deg, rgba(255,255,255,.28) 25%, transparent 25%, transparent 50%, rgba(255,255,255,.28) 50%, rgba(255,255,255,.28) 75%, transparent 75%);
    animation: saListra 1s linear infinite;
}
@keyframes saListra { to { background-position: 28px 0; } }

.aih-lotes .sa-etapas { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.aih-lotes .sa-etapas li { display: flex; align-items: flex-start; gap: 10px; padding: 8px 10px; border-radius: 10px; transition: background .25s; }
.aih-lotes .sa-etapas li.ativa { background: var(--p-blue-soft); }
.aih-lotes .sa-marca { width: 22px; height: 22px; flex: none; display: grid; place-items: center; font-size: 16px; color: var(--p-faint); }
.aih-lotes .sa-etapas li.feita .sa-marca { color: var(--p-green); animation: saCheck .35s ease-out; }
.aih-lotes .sa-etapas li.ativa .sa-marca { color: var(--p-blue); }
@keyframes saCheck { 0% { transform: scale(.3); opacity: 0; } 70% { transform: scale(1.25); } 100% { transform: scale(1); opacity: 1; } }
.aih-lotes .sa-giro { width: 16px; height: 16px; border-radius: 50%; border: 2.5px solid var(--p-blue-line-soft); border-top-color: var(--p-blue); animation: mmSpin .8s linear infinite; }
.aih-lotes .sa-etapa-txt { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.aih-lotes .sa-etapa-tit { font-size: .82rem; font-weight: 700; color: var(--p-ink); }
.aih-lotes .sa-etapas li.espera .sa-etapa-tit { color: var(--p-faint); font-weight: 600; }
.aih-lotes .sa-etapa-det { font-size: .72rem; font-weight: 600; color: var(--p-muted); }

.aih-lotes .sa-resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 4px 0 10px; }
.aih-lotes .sa-num { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; background: var(--p-soft); border: 1px solid var(--p-border-soft); }
.aih-lotes .sa-num > b { font-size: 1.35rem; font-weight: 800; color: var(--p-ink); line-height: 1.1; }
.aih-lotes .sa-num > span { font-size: .68rem; font-weight: 700; color: var(--p-muted); }
.aih-lotes .sa-num.red > b { color: var(--p-red); }
.aih-lotes .sa-num.green > b { color: var(--p-green); }
.aih-lotes .sa-num.amber > b { color: var(--p-orange); }
.aih-lotes .sa-nota { display: flex; gap: 6px; align-items: center; margin: 4px 0 8px; }

@media (prefers-reduced-motion: reduce) {
    .aih-lotes .sa-anel, .aih-lotes .sa-radar > i, .aih-lotes .sa-barra > i, .aih-lotes .sa-giro, .aih-lotes .sa-marca { animation: none !important; }
    .aih-lotes .sa-barra > i { transition: none; }
}

/* ---------- lista de críticas ---------- */
.aih-lotes .sc-aih { border-top: 1px solid var(--p-border-soft); padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; content-visibility: auto; contain-intrinsic-size: auto 160px; }
.aih-lotes .sc-aih:first-child { border-top: 0; }
.aih-lotes .sc-aih-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.aih-lotes .sc-pac { font-size: .8rem; font-weight: 700; color: var(--p-ink); }
.aih-lotes .sc-crit { border: 1px solid var(--p-border-soft); border-left-width: 4px; border-radius: 12px; padding: 9px 12px; display: flex; flex-direction: column; gap: 5px; background: var(--p-surface); }
.aih-lotes .sc-crit.risco { border-left-color: var(--p-red); }
.aih-lotes .sc-crit.aviso { border-left-color: var(--p-orange); }
.aih-lotes .sc-crit-topo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .82rem; color: var(--p-ink); }
.aih-lotes .sc-det { display: flex; gap: 14px; flex-wrap: wrap; font-size: .74rem; color: var(--p-muted); font-weight: 600; }
.aih-lotes .sc-det b { color: var(--p-ink); font-weight: 800; }
.aih-lotes .sc-msg { color: var(--p-muted); overflow-wrap: anywhere; }
.aih-lotes .sc-como {
    display: flex; gap: 8px; align-items: flex-start; padding: 8px 10px; border-radius: 10px;
    background: var(--p-green-soft); border: 1px solid var(--p-green-soft); font-size: .76rem; line-height: 1.5; color: var(--p-text); font-weight: 500;
}
.aih-lotes .sc-como > i { font-size: 16px; color: var(--p-green); flex: none; margin-top: 1px; }
.aih-lotes .sc-como b { color: var(--p-green); font-weight: 800; margin-right: 4px; }

/* ---------- aprendizado com o retorno / base do CNES ---------- */
.aih-lotes .sr-envio { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 10px 0; }
.aih-lotes .sr-envio input[type=file] { max-width: 360px; }
.aih-lotes .sr-lista { display: flex; flex-direction: column; }
.aih-lotes .sr-item { padding: 10px 14px; border-top: 1px solid var(--p-border-soft); display: flex; flex-direction: column; gap: 6px; }
.aih-lotes .sr-item:first-child { border-top: 0; }
.aih-lotes .sr-topo { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .82rem; color: var(--p-ink); }
.aih-lotes .sr-acoes { display: flex; justify-content: flex-end; }
.aih-lotes .sr-nota { display: flex; gap: 6px; align-items: flex-start; margin: 8px 14px; }
.aih-lotes .sr-item textarea { width: 100%; resize: vertical; font-size: .78rem; line-height: 1.45; }
.aih-lotes .sr-hist .mm-grade-h, .aih-lotes .sr-hist .mm-grade-l { grid-template-columns: 150px minmax(0, 1fr) 100px 70px 70px 80px 100px 70px; }
.aih-lotes .sb-grade { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 12px 0; }
.aih-lotes .sb-hist .mm-grade-h, .aih-lotes .sb-hist .mm-grade-l { grid-template-columns: 100px 50px 150px 80px 100px 100px minmax(0, 1fr); }

/* ---------- segunda rodada: por causa, passos, lote, retorno ---------- */
.aih-lotes .sa-etapas li.parou .sa-marca { color: var(--p-red); }
.aih-lotes .sa-etapas li.parou { background: var(--p-red-soft); }

.aih-lotes .sc-causa {
    border-top: 1px solid var(--p-border-soft); border-left: 4px solid var(--p-border-soft); padding: 12px 14px;
    display: flex; flex-direction: column; gap: 8px; content-visibility: auto; contain-intrinsic-size: auto 180px;
}
.aih-lotes .sc-causa.risco { border-left-color: var(--p-red); }
.aih-lotes .sc-causa.aviso { border-left-color: var(--p-orange); }
.aih-lotes .sc-aihs { display: flex; flex-wrap: wrap; gap: 6px; }
.aih-lotes .sc-aih-chip {
    border: 1px solid var(--p-border); background: var(--p-surface); border-radius: 8px; padding: 3px 8px; font-size: .7rem; font-weight: 600;
    color: var(--p-ink); cursor: pointer; transition: border-color .15s, background .15s;
}
.aih-lotes .sc-aih-chip:hover:not(:disabled) { border-color: var(--p-blue); background: var(--p-blue-soft); }
.aih-lotes .sc-aih-chip:disabled { opacity: .6; cursor: default; }

.aih-lotes .sc-como-txt { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.aih-lotes .sc-diag { font-weight: 600; color: var(--p-text); }
.aih-lotes .sc-como-tit { color: var(--p-green); font-weight: 800; margin-top: 2px; }
.aih-lotes .sc-passos { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 2px; }
.aih-lotes .sc-equipe { display: flex; gap: 6px; align-items: flex-start; margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--p-border); color: var(--p-text); }
.aih-lotes .sc-equipe > i { color: var(--p-blue); }
.aih-lotes .sc-equipe b { color: var(--p-blue); }

.aih-lotes .al-sihd2 { margin-top: 4px; }
.aih-lotes .sb-cob .mm-grade-h, .aih-lotes .sb-cob .mm-grade-l { grid-template-columns: 90px minmax(0, 1fr) 80px 100px 100px 100px; }
.aih-lotes .sr-hist .mm-grade-h, .aih-lotes .sr-hist .mm-grade-l { grid-template-columns: 140px minmax(0, 1fr) 90px 66px 56px 76px 76px 100px 150px; }
.aih-lotes .sb-grade { grid-template-columns: 160px 220px; }
.aih-lotes .sr-pend { content-visibility: auto; contain-intrinsic-size: auto 90px; }
.aih-lotes .sr-acoes { align-items: center; gap: 10px; }
