/* Controle de Prazos — identidade sóbria de escritório: azul-marinho, papel quente, destaque âmbar. */
:root {
  --fundo: #f4f2ee; --superficie: #ffffff; --superficie-2: #faf9f6; --linha: #dedad2; --texto: #1c2430; --texto-2: #556070;
  --marinho: #14304d; --marinho-2: #1f4a75; --acento: #b9741a; --link: #1b5a99;
  --critico: #b3261e; --critico-bg: #fbe9e7; --urgente: #b4540a; --urgente-bg: #fdeede; --atencao: #8a6a00; --atencao-bg: #fbf3d3;
  --normal: #1e6b3a; --normal-bg: #e3f3e8; --encerrado: #5b6573; --encerrado-bg: #eceff2;
  --ok: #1e6b3a; --ok-bg: #e3f3e8; --falha: #b3261e; --falha-bg: #fbe9e7; --aviso: #8a6a00; --aviso-bg: #fbf3d3; --info: #1b5a99; --info-bg: #e5eefa;
  --sombra: 0 1px 2px rgba(20, 48, 77, .08), 0 4px 14px rgba(20, 48, 77, .06); --raio: 10px; --foco: 0 0 0 3px rgba(27, 90, 153, .45);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fundo: #10161d; --superficie: #18212b; --superficie-2: #1d2833; --linha: #2c3a49; --texto: #e8edf2; --texto-2: #9fb0c1;
    --marinho: #0c1e31; --marinho-2: #28557f; --acento: #e0a24a; --link: #7fb6f0;
    --critico: #ff8a80; --critico-bg: #3a1c1a; --urgente: #ffb066; --urgente-bg: #3a2614; --atencao: #e8cf6b; --atencao-bg: #332c10;
    --normal: #7fd69b; --normal-bg: #15301f; --encerrado: #9fb0c1; --encerrado-bg: #222d38;
    --ok: #7fd69b; --ok-bg: #15301f; --falha: #ff8a80; --falha-bg: #3a1c1a; --aviso: #e8cf6b; --aviso-bg: #332c10; --info: #7fb6f0; --info-bg: #14283f;
    --sombra: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 14px rgba(0, 0, 0, .3); --foco: 0 0 0 3px rgba(127, 182, 240, .6);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fundo); color: var(--texto); font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.55rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1.02rem; }
a { color: var(--link); }
:focus-visible { outline: none; box-shadow: var(--foco); border-radius: 6px; }
.pular { position: absolute; left: -999px; top: 0; background: var(--marinho); color: #fff; padding: .6rem 1rem; z-index: 100; }
.pular:focus { left: 8px; top: 8px; }
[hidden] { display: none !important; }
.so-leitor { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* topo */
.topo { background: var(--marinho); color: #fff; position: sticky; top: 0; z-index: 20; box-shadow: 0 2px 8px rgba(0, 0, 0, .18); }
.topo-in { max-width: 1280px; margin: 0 auto; padding: .55rem 16px; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.marca { display: flex; align-items: center; gap: .65rem; color: #fff; text-decoration: none; }
.marca-icone { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--acento); color: #14304d; font-weight: 800; }
.marca-nome { display: flex; flex-direction: column; font-weight: 700; line-height: 1.1; }
.marca-nome small { font-weight: 400; opacity: .75; font-size: .72rem; }
.menu { display: flex; gap: .15rem; flex: 1; flex-wrap: wrap; }
.menu a { color: #dce8f4; text-decoration: none; padding: .45rem .75rem; border-radius: 8px; font-weight: 500; }
.menu a:hover { background: rgba(255, 255, 255, .1); }
.menu a[aria-current="page"] { background: rgba(255, 255, 255, .18); color: #fff; }
.usuario { display: flex; align-items: center; gap: .6rem; }
.usuario-nome { font-size: .88rem; opacity: .9; }

main { max-width: 1280px; margin: 0 auto; padding: 18px 16px 64px; }
main:focus { outline: none; }
.carregando { color: var(--texto-2); }
.cabecalho-pagina { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; margin-bottom: 1rem; }
.cabecalho-pagina h1 { margin: 0; }
.sub { color: var(--texto-2); margin: .15rem 0 0; font-size: .92rem; }
.migalha { font-size: .88rem; margin-bottom: .6rem; }

/* botões e campos */
.botao { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border: 1px solid var(--linha); background: var(--superficie); color: var(--texto); padding: .55rem .95rem; border-radius: 8px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; min-height: 40px; }
.botao:hover { background: var(--superficie-2); }
.botao.primario { background: var(--marinho-2); border-color: var(--marinho-2); color: #fff; }
.botao.primario:hover { filter: brightness(1.1); }
.botao.perigo { background: var(--critico); border-color: var(--critico); color: #fff; }
.botao.pequeno { padding: .3rem .65rem; min-height: 32px; font-size: .86rem; }
.botao.fantasma { background: transparent; border-color: rgba(255, 255, 255, .35); color: #fff; }
.botao[disabled] { opacity: .55; cursor: not-allowed; }
label { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .25rem; }
input, select, textarea { width: 100%; font: inherit; color: var(--texto); background: var(--superficie); border: 1px solid var(--linha); border-radius: 8px; padding: .5rem .65rem; min-height: 40px; }
textarea { min-height: 90px; resize: vertical; }
input[type="checkbox"] { width: auto; min-height: 0; }
.campo { margin-bottom: .85rem; }
.campo-check { display: flex; align-items: center; gap: .5rem; } .campo-check label { margin: 0; font-weight: 500; }

/* cartões e avisos */
.cartao { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); box-shadow: var(--sombra); padding: 1rem 1.1rem; }
.cartao + .cartao { margin-top: 1rem; }
.faixa { display: flex; gap: .75rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .7rem 1rem; border-radius: var(--raio); margin-bottom: .85rem; border: 1px solid transparent; }
.faixa strong { margin-right: .35rem; }
.faixa.ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, transparent); }
.faixa.falha { background: var(--falha-bg); color: var(--falha); border-color: color-mix(in srgb, var(--falha) 40%, transparent); }
.faixa.aviso { background: var(--aviso-bg); color: var(--aviso); border-color: color-mix(in srgb, var(--aviso) 35%, transparent); }
.faixa.info { background: var(--info-bg); color: var(--info); border-color: color-mix(in srgb, var(--info) 30%, transparent); }

/* painel */
.grade-kpi { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; margin-bottom: 1.4rem; }
.kpi { display: block; text-decoration: none; color: inherit; background: var(--superficie); border: 1px solid var(--linha); border-left: 5px solid var(--encerrado); border-radius: var(--raio); padding: .75rem .9rem; box-shadow: var(--sombra); }
.kpi:hover { transform: translateY(-1px); border-color: var(--marinho-2); }
.kpi .num { font-size: 2rem; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.kpi .rot { font-size: .86rem; color: var(--texto-2); margin-top: .25rem; display: flex; gap: .35rem; align-items: center; }
.kpi.critico { border-left-color: var(--critico); } .kpi.critico .num { color: var(--critico); }
.kpi.urgente { border-left-color: var(--urgente); } .kpi.urgente .num { color: var(--urgente); }
.kpi.atencao { border-left-color: var(--atencao); } .kpi.atencao .num { color: var(--atencao); }
.kpi.normal { border-left-color: var(--normal); }
.kpi.zero .num { opacity: .45; }
.grade-adv { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; margin-bottom: 1.4rem; }
.adv { display: block; text-decoration: none; color: inherit; background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); padding: .8rem .95rem; box-shadow: var(--sombra); }
.adv:hover { border-color: var(--marinho-2); }
.adv h3 { margin: 0 0 .5rem; }
.adv ul { list-style: none; padding: 0; margin: 0; display: grid; gap: .15rem; font-size: .9rem; }
.adv li { display: flex; justify-content: space-between; gap: .5rem; } .adv li b { font-variant-numeric: tabular-nums; }
.adv li.zero { opacity: .5; }

/* insígnias */
.selo { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 999px; font-size: .78rem; font-weight: 700; white-space: nowrap; border: 1px solid transparent; }
.selo.CRITICO { background: var(--critico-bg); color: var(--critico); border-color: color-mix(in srgb, var(--critico) 35%, transparent); }
.selo.URGENTE { background: var(--urgente-bg); color: var(--urgente); border-color: color-mix(in srgb, var(--urgente) 35%, transparent); }
.selo.ATENCAO { background: var(--atencao-bg); color: var(--atencao); border-color: color-mix(in srgb, var(--atencao) 35%, transparent); }
.selo.NORMAL { background: var(--normal-bg); color: var(--normal); border-color: color-mix(in srgb, var(--normal) 35%, transparent); }
.selo.NENHUMA, .selo.neutro { background: var(--encerrado-bg); color: var(--encerrado); }
.selo.ok { background: var(--ok-bg); color: var(--ok); } .selo.falha { background: var(--falha-bg); color: var(--falha); }
.selo.aviso { background: var(--aviso-bg); color: var(--aviso); } .selo.info { background: var(--info-bg); color: var(--info); }

/* tabela */
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .7rem; align-items: end; }
.filtros .campo { margin: 0; }
.tabela-caixa { overflow-x: auto; border: 1px solid var(--linha); border-radius: var(--raio); background: var(--superficie); box-shadow: var(--sombra); margin-top: 1rem; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .6rem .7rem; border-bottom: 1px solid var(--linha); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-2); background: var(--superficie-2); white-space: nowrap; }
th button { all: unset; cursor: pointer; font: inherit; text-transform: inherit; letter-spacing: inherit; color: inherit; }
th button:focus-visible { box-shadow: var(--foco); }
tbody tr:hover { background: var(--superficie-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td .titulo { font-weight: 600; color: var(--texto); text-decoration: none; } td .titulo:hover { text-decoration: underline; }
td .sec { color: var(--texto-2); font-size: .82rem; display: block; }
.paginacao { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .65rem .8rem; flex-wrap: wrap; color: var(--texto-2); font-size: .88rem; }
.vazio { padding: 2rem 1rem; text-align: center; color: var(--texto-2); }

/* detalhe */
.fatos { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .75rem 1.2rem; margin: 0; }
.fatos dt { font-size: .78rem; color: var(--texto-2); text-transform: uppercase; letter-spacing: .04em; }
.fatos dd { margin: 0 0 .1rem; font-weight: 500; overflow-wrap: anywhere; }
.acoes { display: flex; gap: .5rem; flex-wrap: wrap; margin: 1rem 0 0; }
.linha-tempo { list-style: none; margin: 0; padding: 0; }
.linha-tempo li { display: grid; grid-template-columns: 10rem 1fr; gap: .75rem; padding: .5rem 0; border-bottom: 1px dashed var(--linha); }
.linha-tempo time { color: var(--texto-2); font-size: .84rem; font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .linha-tempo li { grid-template-columns: 1fr; gap: .1rem; } }
.nota { color: var(--texto-2); font-size: .86rem; }
.destaque { font-weight: 700; font-size: 1.05rem; }

/* componentes de saúde */
.grade-saude { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .75rem; }
.componente { background: var(--superficie); border: 1px solid var(--linha); border-radius: var(--raio); padding: .8rem .95rem; box-shadow: var(--sombra); border-left: 5px solid var(--encerrado); }
.componente.OK { border-left-color: var(--ok); } .componente.FALHA { border-left-color: var(--falha); } .componente.ATENCAO { border-left-color: var(--aviso); }
.componente h3 { display: flex; justify-content: space-between; gap: .5rem; align-items: center; margin: 0 0 .25rem; }

/* diálogo, avisos flutuantes */
dialog { border: 1px solid var(--linha); border-radius: 14px; background: var(--superficie); color: var(--texto); padding: 1.2rem 1.3rem; width: min(520px, calc(100vw - 24px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
dialog::backdrop { background: rgba(10, 18, 28, .55); }
dialog form > .botoes { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; flex-wrap: wrap; }
.avisos { position: fixed; right: 12px; bottom: 12px; display: grid; gap: .5rem; z-index: 60; max-width: min(420px, calc(100vw - 24px)); }
.toast { background: var(--marinho); color: #fff; padding: .7rem .95rem; border-radius: 10px; box-shadow: var(--sombra); }
.toast.erro { background: var(--critico); }

/* páginas simples (login, link de ciência) */
.pagina-simples { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.cartao-central { background: var(--superficie); border: 1px solid var(--linha); border-radius: 14px; box-shadow: var(--sombra); padding: 1.6rem; width: min(480px, 100%); text-align: center; }

/* celular: tabelas viram cartões */
@media (max-width: 760px) {
  .topo-in { gap: .4rem; } .marca-nome small { display: none; }
  .menu { order: 3; flex: 1 1 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: .2rem; } .menu a { white-space: nowrap; }
  .usuario { margin-left: auto; } .usuario-nome { display: none; }
  table.responsiva thead { display: none; }
  table.responsiva, table.responsiva tbody, table.responsiva tr, table.responsiva td { display: block; width: 100%; }
  table.responsiva tr { padding: .6rem .7rem; border-bottom: 1px solid var(--linha); }
  table.responsiva td { border: 0; padding: .12rem 0; }
  table.responsiva td[data-rotulo]::before { content: attr(data-rotulo) ": "; color: var(--texto-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; }
  td.num { text-align: left; }
  .grade-kpi { grid-template-columns: repeat(2, 1fr); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
@media print { .topo, .acoes, .filtros, .avisos { display: none !important; } body { background: #fff; } }

/* filtros recolhíveis e detalhe */
.filtros-caixa { padding: .35rem .9rem; }
.filtros-caixa summary { cursor: pointer; font-weight: 700; padding: .45rem 0; list-style-position: inside; }
.filtros-caixa form { padding: .4rem 0 .6rem; }
fieldset.prio { border: 0; padding: 0; margin: 0; min-width: 0; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem .9rem; }
.fatos .fato { min-width: 0; }
.fatos dd { margin: 0; }
.menu a.aba { color: var(--texto); }
.menu:has(a.aba) { margin-bottom: 1rem; flex-wrap: wrap; }
.menu a.aba[aria-current="page"] { background: var(--marinho-2); color: #fff; }
.menu a.aba:hover { background: var(--superficie-2); }

/* bancas, resumo e links para o DataJuri */
.chips-banca { display: flex; flex-wrap: wrap; gap: .3rem; margin: .1rem 0 .5rem; }
.chip-banca { display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; border: 1px solid var(--linha); color: var(--texto-2); background: var(--superficie-2); white-space: nowrap; }
.adv h3 { margin-bottom: .2rem; }
.texto-longo { white-space: pre-line; overflow-wrap: anywhere; margin: .6rem 0; }
.resumo-linha { color: var(--texto); font-size: .86rem; display: block; margin-top: .15rem; overflow-wrap: anywhere; }
.link-dj { font-size: .78rem; white-space: nowrap; margin-left: .35rem; }
.links-dj { display: flex; flex-wrap: wrap; gap: .5rem; margin: .6rem 0 0; }
