:root {
  --fundo: #f3f5f8; --cartao: #ffffff; --texto: #1c2430; --suave: #5b6676; --borda: #d7dde5;
  --azul: #1f4e8c; --azul-claro: #e7eef8; --verde: #1d7a46; --verde-claro: #e3f3ea;
  --laranja: #b65c00; --laranja-claro: #fdf0e0; --vermelho: #b42318; --vermelho-claro: #fdecea;
  --raio: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.45 Lato, "Segoe UI", system-ui, sans-serif; background: var(--fundo); color: var(--texto); }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0 0 .4em; line-height: 1.2; }
h1, h2, .marca b { font-family: Cinzel, Georgia, "Times New Roman", serif; letter-spacing: .02em; }
.idade { color: var(--azul); font-weight: 600; min-height: 1em; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.05rem; }
small { color: var(--suave); font-weight: 400; }

.btn { font: inherit; border: 1px solid var(--borda); background: #fff; color: var(--texto); padding: 8px 16px; border-radius: 8px; cursor: pointer; }
.btn:hover { border-color: var(--azul); }
.btn.primario { background: var(--azul); border-color: var(--azul); color: #fff; font-weight: 600; }
.btn.primario:hover { background: #173d6f; }
.btn.perigo { color: var(--vermelho); border-color: #f0c2bd; }
.btn.gravar { background: var(--vermelho); color: #fff; border-color: var(--vermelho); font-weight: 600; }
.btn.link { border: 0; background: none; color: inherit; padding: 4px 8px; text-decoration: underline; }
.btn.peq { padding: 4px 10px; font-size: .88rem; }
.btn:disabled { opacity: .5; cursor: default; }

/* login */
.tela-login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: linear-gradient(160deg, #1f4e8c, #0f2a4d); }
.cartao { background: var(--cartao); border-radius: var(--raio); padding: 20px; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.login { width: 100%; max-width: 380px; display: grid; gap: 12px; padding: 28px; }
.login h1 { font-size: 1.45rem; color: var(--azul); margin: 0; text-align: center; }
.login .brasao { width: 64px; height: 64px; margin: 0 auto; }
.sub { margin: -6px 0 6px; color: var(--suave); text-align: center; }
.aviso { background: var(--azul-claro); padding: 10px; border-radius: 8px; margin: 0 0 8px; }
.msg-erro { color: var(--vermelho); margin: 0; min-height: 1.2em; }

/* topo */
.topo { background: #12345f; color: #fff; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 20px; padding: 10px 20px; position: sticky; top: 0; z-index: 10; }
.marca { display: flex; align-items: center; gap: 10px; }
.marca img { width: 38px; height: 38px; }
.marca b { display: block; font-size: 1.08rem; font-weight: 700; }
.marca span { display: block; font-weight: 400; font-size: .8rem; color: #cfe0f5; }
#abas { display: flex; flex-wrap: wrap; gap: 4px; flex: 1; }
#abas button { font: inherit; background: transparent; color: #cfe0f5; border: 0; padding: 8px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; }
#abas button:hover { background: rgba(255,255,255,.08); color: #fff; }
#abas button.ativa { background: #fff; color: #12345f; }
.quem { font-size: .9rem; display: flex; align-items: center; gap: 4px; }
main { max-width: 1100px; margin: 0 auto; padding: 20px 16px 60px; }

/* formulários */
label { display: grid; gap: 4px; font-weight: 600; font-size: .9rem; }
input, select, textarea { font: inherit; font-weight: 400; padding: 8px 10px; border: 1px solid var(--borda); border-radius: 8px; background: #fff; width: 100%; color: var(--texto); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--azul); outline-offset: -1px; border-color: var(--azul); }
textarea { resize: vertical; }
.registro { display: grid; gap: 16px; }
.cab-form { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.data-auto { background: var(--azul-claro); color: var(--azul); padding: 6px 12px; border-radius: 8px; font-size: .9rem; }
fieldset { border: 1px solid var(--borda); border-radius: var(--raio); background: var(--cartao); padding: 16px 18px 18px; margin: 0; display: grid; gap: 12px; }
legend { font-weight: 700; font-size: 1.05rem; padding: 0 6px; display: flex; align-items: center; gap: 8px; }
.num { background: var(--azul); color: #fff; width: 26px; height: 26px; border-radius: 50%; display: inline-grid; place-items: center; font-size: .85rem; }
.grade { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.grade .larga { grid-column: 1 / -1; }
.rotulo { font-weight: 600; font-size: .9rem; }
.opcoes { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--borda); padding: 7px 12px; border-radius: 999px; cursor: pointer; font-weight: 500; background: #fff; }
.chip input { width: auto; margin: 0; }
.chip:has(input:checked) { background: var(--azul-claro); border-color: var(--azul); color: var(--azul); font-weight: 600; }
.chk { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.chk input { width: 18px; height: 18px; }
.sim-nao { display: grid; gap: 6px; }
.sim-nao > div { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; padding: 8px 0; border-bottom: 1px dashed var(--borda); }
.sim-nao > div:last-child { border-bottom: 0; }
.sim-nao span { min-width: 260px; font-weight: 600; font-size: .9rem; }
.sim-nao label { display: inline-flex; align-items: center; gap: 6px; font-weight: 500; cursor: pointer; }
.sim-nao input { width: auto; }
.enc-detalhe { display: grid; gap: 12px; padding-left: 4px; }
.acoes { display: flex; justify-content: flex-end; gap: 10px; }
.acoes .btn.primario { padding: 10px 26px; font-size: 1rem; }

/* gravador */
.gravador { display: grid; gap: 8px; }
.gravador video { width: 100%; max-width: 480px; background: #111; border-radius: 8px; aspect-ratio: 4/3; }
.gravador .controles { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rec { color: var(--vermelho); font-weight: 700; }
.rec::before { content: ""; display: inline-block; width: 10px; height: 10px; background: var(--vermelho); border-radius: 50%; margin-right: 6px; animation: pisca 1s infinite; }
@keyframes pisca { 50% { opacity: .2; } }
.ok-video { color: var(--verde); font-weight: 600; }
.barra-envio { height: 8px; background: var(--borda); border-radius: 4px; overflow: hidden; max-width: 480px; }
.barra-envio div { height: 100%; background: var(--verde); width: 0; transition: width .2s; }

/* filtros e tabelas */
.filtros { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; background: var(--cartao); padding: 14px; border-radius: var(--raio); border: 1px solid var(--borda); margin-bottom: 14px; }
.filtros label { min-width: 150px; }
.filtros .busca { flex: 1; min-width: 200px; }
.tabela-envolve { overflow-x: auto; background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--borda); vertical-align: top; }
th { background: #f8fafc; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--suave); }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f7f9fc; }
td.n { text-align: right; font-variant-numeric: tabular-nums; }
.etq { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.etq.at { background: var(--azul-claro); color: var(--azul); }
.etq.in { background: #efe8f9; color: #5b3a92; }
.etq.dia { background: var(--verde-claro); color: var(--verde); }
.etq.ag { background: var(--laranja-claro); color: var(--laranja); }
.etq.sem { background: #eef0f3; color: var(--suave); }
.etq.vul { background: var(--vermelho-claro); color: var(--vermelho); }
.vazio { padding: 30px; text-align: center; color: var(--suave); }
.cabecalho { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }

/* painel */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--cartao); border: 1px solid var(--borda); border-radius: var(--raio); padding: 14px 16px; }
.kpi .v { font-size: 1.9rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .r { color: var(--suave); font-size: .85rem; }
.graficos { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; margin-bottom: 16px; }
.barras { display: grid; gap: 8px; }
.barra { display: grid; grid-template-columns: minmax(120px, 190px) 1fr 40px; gap: 10px; align-items: center; font-size: .88rem; }
.barra .trilho { background: #eef1f5; border-radius: 4px; height: 14px; overflow: hidden; }
.barra .trilho div { background: var(--azul); height: 100%; border-radius: 4px; }
.barra .trilho.verde div { background: var(--verde); }
.barra .trilho.laranja div { background: var(--laranja); }
.barra .trilho.roxo div { background: #6a46a8; }
.barra b { text-align: right; font-variant-numeric: tabular-nums; }
.atalhos { display: flex; gap: 6px; flex-wrap: wrap; }

/* detalhe e modal */
dialog { border: 0; border-radius: 12px; padding: 0; width: min(760px, calc(100vw - 32px)); max-height: calc(100vh - 40px); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(10,20,35,.5); }
#modalCorpo { padding: 22px; }
.det { display: grid; gap: 14px; }
.det section { border: 1px solid var(--borda); border-radius: var(--raio); padding: 12px 14px; }
.det h3 { color: var(--azul); }
.det dl { display: grid; grid-template-columns: 200px 1fr; gap: 4px 12px; margin: 0; }
.det dt { color: var(--suave); font-size: .88rem; }
.det dd { margin: 0; white-space: pre-wrap; word-break: break-word; }
.det video { width: 100%; border-radius: 8px; background: #111; }
.rodape-modal { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* assinatura do desenvolvedor */
.pfc { display: flex; align-items: center; justify-content: center; gap: 12px; color: var(--suave); }
.pfc img { width: 40px; height: 40px; border-radius: 8px; }
.pfc span { font-size: 12px; line-height: 1.25; text-align: left; }
.pfc b { display: block; font-size: 14px; font-weight: 700; color: var(--texto); }
.login .pfc { margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--borda); }
.rodape-pfc { margin: 0 0 24px; }

#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: #1c2430; color: #fff; padding: 12px 20px; border-radius: 8px; z-index: 100; box-shadow: 0 6px 20px rgba(0,0,0,.25); max-width: calc(100vw - 32px); }
#toast.erro { background: var(--vermelho); }

@media (max-width: 640px) {
  .topo { padding: 10px 16px; }
  .quem { width: 100%; justify-content: space-between; font-size: .82rem; }
  #abas button { padding: 6px 10px; font-size: .88rem; }
  main { padding: 14px 12px 50px; }
  /* tabela vira lista de cartões no celular */
  .tabela-envolve.cartoes { background: none; border: 0; }
  .cartoes table, .cartoes tbody, .cartoes tr, .cartoes td { display: block; width: 100%; }
  .cartoes thead { display: none; }
  .cartoes tr { background: #fff; border: 1px solid var(--borda); border-radius: 10px; margin-bottom: 10px; padding: 8px 4px; }
  .cartoes td { border: 0; padding: 3px 10px; }
  .cartoes td[data-l]:not([data-l=""])::before { content: attr(data-l) ": "; color: var(--suave); font-size: .8rem; }
  .cartoes td:empty { display: none; }
  .filtros label { min-width: calc(50% - 6px); flex: 1; }
  .sim-nao span { min-width: 100%; }
  .det dl { grid-template-columns: 1fr; }
  .barra { grid-template-columns: 110px 1fr 34px; }
}
@media print {
  .topo, .filtros, .acoes, .rodape-modal, .rodape-pfc { display: none !important; }
}
