/* ═══════════════════════════════════════════════════════════════════════
   Ideal Assessoria Médica — Estação de Revisão de Contratos

   Identidade visual herdada do protótipo (Ideal_prototipo_faturamento):
   mesmos tokens, mesma tipografia, mesmos componentes de base — header,
   stepper, page-shell, panel, field, button. O cliente vê o protótipo
   que aprovou.

   O que vem depois de "COMPONENTES DA ESTAÇÃO" não existe no protótipo:
   são as peças que a operação real exige — visor de PDF lado a lado,
   fila de decisões, barra de ação fixa, bloqueios de cálculo. Escritas
   no mesmo idioma: raio 18px, borda warm-gray, sombra suave, vinho no
   que exige atenção.
   ═══════════════════════════════════════════════════════════════════ */

:root {
  --red: #a51c30;
  --red-hover: #881526;
  --wine: #681524;
  --graphite: #15252c;
  --graphite-soft: #35454b;
  --warm-gray: #e8e3df;
  --paper: #f7f4f1;
  --white: #ffffff;
  --border: #d8d2cd;
  --muted: #657177;
  --success: #26734d;
  --error: #a51c30;
  --shadow: 0 18px 50px rgba(21, 37, 44, 0.09);
  --radius: 18px;

  /* acrescentados: o protótipo não tem estado de atenção */
  --attention: #8a5a12;
  --attention-bg: #fdf6e9;
  --attention-border: #e8d5ae;
  --success-bg: #eef6f1;
  --error-bg: #fff1f2;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: light; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--white);
  color: var(--graphite);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  /* coluna flex: a tela de revisão precisa que o <main> ocupe exatamente o
     que sobra depois do cabeçalho e do stepper. Altura fixa em calc() quebra
     assim que qualquer um dos dois muda de altura — e o stepper mudou. */
  display: flex;
  flex-direction: column;
}
.site-header, .progress, .site-footer { flex: none; }

/* Só a tela de revisão trava a altura: o PDF fica parado e o painel de
   trabalho rola por dentro. `min-height: 100vh` no body não serve aqui —
   ele cresce com o conteúdo e a página inteira volta a rolar. */
html:has(> body.tela-cheia) { height: 100%; overflow: hidden; }
body.tela-cheia { height: 100%; overflow: hidden; }

button, input, select, textarea { font: inherit; }
a { color: inherit; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

.skip-link {
  position: fixed; left: 16px; top: -80px; z-index: 100;
  border-radius: 8px; background: var(--graphite); color: var(--white);
  padding: 10px 14px; text-decoration: none;
}
.skip-link:focus { top: 16px; }

/* ───────────────────────────────────────────────── cabeçalho e marca */

.site-header {
  min-height: 82px; display: flex; align-items: center;
  justify-content: space-between; gap: 24px;
  border-bottom: 1px solid var(--warm-gray);
  padding: 16px clamp(20px, 5vw, 72px);
}
.brand { display: inline-flex; align-items: center; gap: 14px; min-width: max-content;
         text-decoration: none; }
.brand-mark { position: relative; width: 48px; height: 48px; display: inline-block; }
.brand-mark i, .brand-mark b {
  position: absolute; width: 29px; height: 29px;
  border: 5px solid var(--red); border-radius: 7px;
}
.brand-mark i { left: 2px; top: 3px; border-color: #c53b50; }
.brand-mark b { right: 2px; bottom: 3px; border-color: var(--red); }
.brand-name {
  display: grid; color: var(--graphite); font-size: 24px; font-weight: 500;
  letter-spacing: 0.18em; line-height: 1;
}
.brand-name small {
  margin-top: 6px; color: var(--graphite-soft); font-size: 8px;
  font-weight: 700; letter-spacing: 0.08em;
}
.header-aside { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); }

/* ─────────────────────────────────────────────────────────── stepper */

.progress {
  border-bottom: 1px solid var(--warm-gray); background: var(--paper);
  overflow-x: auto; padding: 18px clamp(20px, 5vw, 72px);
}
.progress ol {
  width: min(940px, 100%); margin: 0 auto; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(120px, 1fr)); list-style: none;
}
.progress li {
  position: relative; display: grid; justify-items: center; gap: 7px;
  color: var(--muted); font-size: 12px; text-align: center;
}
.progress li::before {
  position: absolute; top: 15px; left: -50%; width: 100%; height: 2px;
  background: var(--border); content: "";
}
.progress li:first-child::before { display: none; }
.progress li span {
  z-index: 1; width: 32px; height: 32px; display: grid; place-items: center;
  border: 2px solid var(--border); border-radius: 50%;
  background: var(--white); font-weight: 700;
}
.progress li strong { font-weight: 600; white-space: nowrap; }
.progress .is-complete::before, .progress .is-current::before { background: var(--red); }
.progress .is-complete span, .progress .is-current span {
  border-color: var(--red); background: var(--red); color: var(--white);
}
.progress .is-current { color: var(--graphite); }

/* ─────────────────────────────────────────────── página e tipografia */

.page-shell { width: min(860px, calc(100% - 40px)); margin: 0 auto; padding: 62px 0 72px; }
.page-shell.wide { width: min(1120px, calc(100% - 40px)); }
.page-heading { margin-bottom: 32px; }
.eyebrow {
  margin: 0 0 12px; color: var(--red); font-size: 13px; font-weight: 700;
  letter-spacing: 0.1em; text-transform: uppercase;
}
h1, h2, p { overflow-wrap: break-word; }
h1 {
  margin: 0; max-width: 900px; color: var(--graphite);
  font-size: clamp(28px, 4vw, 44px); font-weight: 650;
  letter-spacing: -0.035em; line-height: 1.08;
}
.page-heading > p:last-child { max-width: 720px; margin: 16px 0 0; color: var(--muted); font-size: 17px; }

.panel, .plan-card, .review-card {
  border: 1px solid var(--warm-gray); border-radius: var(--radius);
  background: var(--white); box-shadow: var(--shadow);
}
.panel { padding: clamp(22px, 5vw, 42px); }
.empty-state { margin: 0; color: var(--muted); font-style: italic; }
.muted { color: var(--muted); font-size: 13px; }
.mono { font-family: var(--mono); font-size: 13px; }
.dir { text-align: right; }

/* ────────────────────────────────────────────── upload, campos, botões */

.upload-card {
  min-height: 200px; display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 8px; border: 2px dashed var(--border);
  border-radius: 16px; background: var(--paper); cursor: pointer;
  padding: 28px; text-align: center; transition: 160ms ease; position: relative;
}
.upload-card:hover, .upload-card:focus-within {
  border-color: var(--red); background: #fcf7f7;
  box-shadow: 0 0 0 4px rgba(165, 28, 48, 0.1); transform: translateY(-2px);
}
.upload-card input {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.upload-card strong { font-size: 19px; }
.upload-card > span:last-of-type { color: var(--muted); font-size: 13px; }
.upload-icon {
  min-width: 58px; height: 58px; display: grid; place-items: center;
  border-radius: 14px; background: var(--wine); color: var(--white);
  font-size: 13px; font-weight: 800; letter-spacing: 0.04em;
}

.field { min-width: 0; display: grid; align-content: start; gap: 7px; }
.field label { color: var(--graphite); font-size: 14px; font-weight: 700; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  background: var(--white); color: var(--graphite); padding: 12px 14px;
  outline: none; transition: 140ms ease;
}
.field input:focus, .field select:focus, .field textarea:focus,
.barra-acao input:focus, .entrada:focus {
  border-color: var(--red); box-shadow: 0 0 0 4px rgba(165, 28, 48, 0.1);
}

.actions { margin-top: 30px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.actions-end { justify-content: flex-end; }

.button {
  min-height: 48px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid transparent; border-radius: 10px; cursor: pointer;
  font-weight: 700; padding: 11px 22px; text-align: center; text-decoration: none;
  transition: 150ms ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; }
.button:focus-visible, .clear-demo:focus-visible, .link-pag:focus-visible {
  outline: 3px solid rgba(165, 28, 48, 0.28); outline-offset: 3px;
}
.button.primary { background: var(--red); color: var(--white); }
.button.primary:hover:not(:disabled) { background: var(--red-hover); }
.button.secondary { border-color: var(--border); background: var(--white); color: var(--graphite); }
.button.secondary:hover { border-color: var(--graphite); }
.button.tertiary { border-color: #dcc2c7; background: #fff7f8; color: var(--wine); }
.button.parcial { background: var(--attention); border-color: var(--attention); color: var(--white); }
.button.parcial:hover:not(:disabled) { background: #74490c; }
.button.pequeno { min-height: 38px; padding: 8px 16px; font-size: 14px; }

.clear-demo {
  border: 0; border-bottom: 1px solid transparent; background: transparent;
  color: var(--muted); cursor: pointer; font-size: 13px; padding: 6px 0;
  text-decoration: none;
}
.clear-demo:hover, .clear-demo:focus-visible { border-color: currentColor; color: var(--red); }

/* ───────────────────────────────────────────────────── avisos e selos */

.aviso {
  margin-bottom: 22px; border-left: 4px solid var(--error); border-radius: 8px;
  background: var(--error-bg); color: #7d1222; padding: 14px 16px; font-size: 14px;
}
.aviso.atencao { border-left-color: var(--attention); background: var(--attention-bg); color: var(--attention); }
.aviso code { font-family: var(--mono); font-size: 13px; }

.selo {
  display: inline-block; padding: 3px 11px; border-radius: 20px;
  font-size: 12px; font-weight: 700; letter-spacing: .01em;
}
.selo.ok { background: var(--success-bg); color: var(--success); }
.selo.fila { background: var(--paper); color: var(--graphite-soft); border: 1px solid var(--border); }
.selo.processando { background: var(--attention-bg); color: var(--attention); }
.selo.falha { background: var(--error-bg); color: var(--error); }

/* ═══════════════════════════════════════════════════════════════════
   COMPONENTES DA ESTAÇÃO — não existem no protótipo
   ═══════════════════════════════════════════════════════════════════ */

/* painel de números da fila */
.metricas { display: flex; flex-wrap: wrap; gap: 14px; margin-bottom: 28px; }
.metrica {
  flex: 1; min-width: 130px; border: 1px solid var(--warm-gray);
  border-radius: 14px; background: var(--white); padding: 16px 18px;
  box-shadow: var(--shadow);
}
.metrica.atencao { border-color: var(--attention-border); background: var(--attention-bg); }
.metrica .num { display: block; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.metrica .rot { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; }

/* lista de contratos */
.lista { width: 100%; border-collapse: collapse; }
.lista th {
  text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 0 16px 12px; font-weight: 700;
}
.lista td { padding: 16px; border-top: 1px solid var(--warm-gray); font-size: 15px; }
.lista tr:hover td { background: var(--paper); }
.lista td strong { display: block; font-weight: 700; }
.acao { color: var(--red); font-weight: 700; text-decoration: none; font-size: 14px; }
.acao:hover { text-decoration: underline; }

/* revisão: PDF à esquerda, trabalho à direita */
main.revisao {
  display: grid; grid-template-columns: minmax(340px, 42%) 1fr;
  flex: 1; min-height: 0;   /* min-height:0 deixa o filho rolar em vez de esticar o grid */
}
.painel-pdf { border-right: 1px solid var(--warm-gray); background: var(--paper); }
.painel-pdf iframe { width: 100%; height: 100%; border: none; display: block; }
.sem-pdf {
  height: 100%; display: flex; flex-direction: column; justify-content: center;
  gap: 10px; padding: 40px; text-align: center; color: var(--muted);
}
.sem-pdf p { margin: 0; max-width: 34ch; align-self: center; }
.painel-revisao { overflow-y: auto; padding: 34px clamp(20px, 3vw, 40px) 110px; }

.cabecalho-contrato { margin-bottom: 26px; }
.cabecalho-contrato h1 { font-size: 27px; }
.cabecalho-contrato h1 span { color: var(--muted); font-weight: 400; }
.cabecalho-contrato p { margin: 10px 0 0; }

/* etapa numerada, no idioma do stepper */
.etapa { margin-bottom: 34px; }
.etapa-cab { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.passo {
  flex: none; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid var(--red); background: var(--red); color: var(--white);
  font-size: 14px; font-weight: 700; display: grid; place-items: center;
}
.passo.alerta { border-color: var(--attention); background: var(--attention); }
.etapa-cab h2 { margin: 0 0 5px; font-size: 21px; font-weight: 650; letter-spacing: -0.02em; }
.explica { margin: 0; color: var(--muted); font-size: 15px; }
.atalho { display: block; margin-top: 8px; font-size: 13px; }

kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border); background: var(--paper); color: var(--graphite-soft);
}

details.recolhivel { border-top: 1px solid var(--warm-gray); padding-top: 18px; margin-bottom: 18px; }
details.recolhivel > summary { cursor: pointer; list-style: none; display: flex; gap: 12px; align-items: baseline; }
details.recolhivel > summary::-webkit-details-marker { display: none; }
details.recolhivel > summary h2 { margin: 0; font-size: 16px; font-weight: 700; }
details.recolhivel > summary h2::after { content: " ▾"; color: var(--muted); font-weight: 400; }
details.recolhivel[open] > summary h2::after { content: " ▴"; }
details.recolhivel[open] > summary { margin-bottom: 16px; }

/* cartão de decisão — o objeto central */
.decisao {
  border: 1px solid var(--warm-gray); border-radius: var(--radius);
  background: var(--white); box-shadow: var(--shadow);
  padding: 20px 22px; margin-bottom: 16px; outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.decisao.critica { border-left: 4px solid var(--red); }
.decisao.em-foco { border-color: var(--red); box-shadow: 0 0 0 4px rgba(165,28,48,.1), var(--shadow); }
.decisao.feita { background: var(--paper); box-shadow: none; }
.decisao.feita .marca-ok { opacity: 1; }
.decisao.feita .trecho, .decisao.feita .opcoes { opacity: .6; }

.decisao header { display: flex; align-items: center; gap: 11px; flex-wrap: wrap; margin-bottom: 12px; }
.decisao .num {
  flex: none; width: 24px; height: 24px; border-radius: 6px; font-size: 13px; font-weight: 700;
  background: var(--warm-gray); color: var(--graphite-soft); display: grid; place-items: center;
}
.decisao.em-foco .num { background: var(--red); color: var(--white); }
.decisao header .rotulo { font-weight: 700; font-size: 15px; }
.marca-ok { margin-left: auto; color: var(--success); font-weight: 700; font-size: 18px; opacity: 0; transition: opacity .14s; }

.tag {
  font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700;
  background: var(--error-bg); color: var(--red); padding: 3px 9px; border-radius: 5px;
}
.link-pag {
  background: var(--white); border: 1px solid var(--border); color: var(--wine);
  padding: 5px 11px; font-size: 12px; font-weight: 700; border-radius: 8px; cursor: pointer;
}
.link-pag:hover { border-color: var(--red); color: var(--red); }
.decisao header .link-pag { margin-left: auto; }
.decisao header .marca-ok + .link-pag { margin-left: 0; }

.trecho {
  margin: 0 0 14px; padding: 12px 16px; border-left: 3px solid var(--border);
  background: var(--paper); border-radius: 0 10px 10px 0;
  color: var(--graphite-soft); font-size: 14px; font-style: italic;
}

.opcoes { display: grid; gap: 8px; }
.opcao {
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 12px 16px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--white); transition: 140ms ease;
}
.opcao:hover { border-color: var(--graphite-soft); }
.opcao:has(input:checked) { border-color: var(--red); background: #fdf7f8; box-shadow: inset 0 0 0 1px var(--red); }
.opcao input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.opcao kbd { flex: none; }
.opcao .valor { font-family: var(--mono); font-size: 15px; word-break: break-word; }
.opcao .modelo { margin-left: auto; flex: none; color: var(--muted); font-size: 12px; }
.opcao .entrada {
  flex: 1; font: inherit; font-size: 15px; padding: 8px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--white); outline: none;
}

/* o contrato em português */
.resumo { display: grid; gap: 16px; }
.bloco-resumo {
  border: 1px solid var(--warm-gray); border-radius: var(--radius);
  background: var(--white); box-shadow: var(--shadow); padding: 20px 24px;
}
.bloco-resumo h3 {
  margin: 0 0 10px; color: var(--wine); font-size: 13px;
  text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
}
.bloco-resumo ul { margin: 0; padding-left: 20px; }
.bloco-resumo li { font-size: 15px; margin-bottom: 5px; }

/* pendências */
.pendencias { list-style: none; margin: 0; padding: 0; }
.pendencias li {
  padding: 14px 18px; margin-bottom: 10px; border-radius: 10px; font-size: 15px;
  background: var(--attention-bg); border-left: 4px solid var(--attention); color: #6b460e;
}
.pendencias li.p-nao_modelada, .pendencias li.p-dependencia,
.pendencias li.p-anexo_ausente, .pendencias li.p-ambiguidade {
  background: var(--error-bg); border-left-color: var(--red); color: #7d1222;
}
.pendencias .link-pag { margin-left: 10px; }

.lista-simples { list-style: none; margin: 0; padding: 0; }
.lista-simples li {
  display: flex; gap: 16px; align-items: baseline; padding: 9px 0;
  border-bottom: 1px solid var(--warm-gray); font-size: 14px;
}
.lista-simples li:last-child { border-bottom: none; }
.lista-simples .rotulo { color: var(--muted); min-width: 230px; flex: none; font-size: 13px; }
.lista-simples .valor { font-family: var(--mono); font-size: 13px; word-break: break-word; }

/* barra fixa de ação */
.barra-acao {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 14px clamp(20px, 3vw, 40px);
  background: var(--white); border-top: 1px solid var(--warm-gray);
  box-shadow: 0 -14px 40px rgba(21, 37, 44, 0.08);
}
.barra-acao.aprovado { border-top: 3px solid var(--success); font-size: 15px; }
.progresso { flex: 1; min-width: 210px; display: flex; align-items: center; gap: 14px; font-size: 14px; }
.progresso .trilho { flex: 1; max-width: 210px; height: 6px; border-radius: 3px; background: var(--warm-gray); overflow: hidden; }
.progresso .preenchido { height: 100%; width: 0; background: var(--red); transition: width .22s; }
#texto-progresso { color: var(--muted); white-space: nowrap; }
#texto-progresso.pronto { color: var(--success); font-weight: 700; }
.barra-acao input[type=text] {
  font: inherit; font-size: 15px; padding: 11px 14px; width: 190px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--white); outline: none;
}

.pulsando {
  width: 42px; height: 42px; margin: 0 auto 22px; border-radius: 50%;
  border: 4px solid var(--warm-gray); border-top-color: var(--red);
  animation: girar 900ms linear infinite;
}
@keyframes girar { to { transform: rotate(360deg); } }

.erro-detalhe {
  font-family: var(--mono); font-size: 13px; white-space: pre-wrap; word-break: break-word;
  background: var(--paper); border: 1px solid var(--warm-gray); border-radius: 10px;
  padding: 14px 16px; margin: 0; color: var(--wine);
}

.site-footer {
  border-top: 1px solid var(--warm-gray); color: var(--muted);
  font-size: 12px; padding: 22px; text-align: center;
}

/* ───────────────────────────────────────────────────────── responsivo */

@media (max-width: 900px) {
  main.revisao { grid-template-columns: 1fr; height: auto; }
  .painel-pdf { height: 58vh; border-right: none; border-bottom: 1px solid var(--warm-gray); }
}

@media (max-width: 760px) {
  .site-header { align-items: flex-start; flex-direction: column; gap: 8px; }
  .progress { padding-inline: 14px; }
  .progress ol { width: 560px; }
  .page-shell, .page-shell.wide { width: min(100% - 28px, 860px); padding-top: 42px; }
  .metricas .metrica { min-width: calc(50% - 7px); }
  .lista-simples li { flex-direction: column; gap: 2px; }
  .lista-simples .rotulo { min-width: 0; }
  .barra-acao { flex-direction: column; align-items: stretch; }
  .barra-acao input[type=text], .barra-acao .button { width: 100%; }
  .opcao { flex-wrap: wrap; }
  .opcao .modelo { margin-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
  .pulsando { animation-duration: 3s; }
}

/* ─────────────────────────────────────────────── login e identidade */

.usuario-atual {
  font-size: 13px; font-weight: 700; color: var(--graphite);
  padding: 4px 12px; border-radius: 20px; background: var(--paper);
  border: 1px solid var(--warm-gray);
}
.quem-aprova { font-size: 13.5px; color: var(--muted); white-space: nowrap; }
.quem-aprova b { color: var(--graphite); }

body.tela-entrar {
  display: grid; place-items: center; min-height: 100vh;
  background: var(--paper); padding: 24px;
}
.entrar-caixa { width: min(430px, 100%); display: grid; gap: 22px; justify-items: center; }
.entrar-caixa .brand { text-decoration: none; }
.entrar-painel { width: 100%; padding: 34px clamp(24px, 6vw, 40px); }
.entrar-painel h1 { font-size: 27px; margin-bottom: 6px; }
.entrar-sub { margin: 0 0 24px; font-size: 14.5px; }
.entrar-painel .actions { margin-top: 26px; }
.entrar-rodape { margin: 0; font-size: 13.5px; }
.entrar-rodape a { color: var(--muted); text-decoration: none; }
.entrar-rodape a:hover { color: var(--red); text-decoration: underline; }
