:root {
  --verde-escuro: #1A3C2E;
  --verde: #2C6E49;
  --verde-claro: #52A87C;
  --verde-fundo: #EEF5F0;
  --dourado: #C9A961;
  --tinta: #1C2420;
  --tinta-2: #55625B;
  --linha: #DCE3DE;
  --fundo: #F6F8F6;
  --branco: #FFFFFF;
  --alerta: #B54708;
  --alerta-fundo: #FEF3E2;
  --erro: #B42318;
  --erro-fundo: #FDECEA;
  --azul: #1E2547;
  --raio: 10px;
  --sombra: 0 1px 2px rgba(16, 40, 28, .06), 0 2px 8px rgba(16, 40, 28, .05);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--tinta);
  font-size: 15px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--fundo); line-height: 1.45; }
a { color: var(--verde); }
h1, h2, h3 { margin: 0 0 .5rem; line-height: 1.2; color: var(--verde-escuro); }
h1 { font-size: 1.4rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
.muted { color: var(--tinta-2); font-size: .9rem; }
.small { font-size: .82rem; }

/* topo */
.topo { background: var(--verde-escuro); color: #fff; display: flex; align-items: center; gap: 1rem; padding: .6rem 1.2rem; position: sticky; top: 0; z-index: 10; }
.topo .marca { font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: .5rem; color: #fff; text-decoration: none; }
.topo .marca img { width: 34px; height: auto; background: #fff; border-radius: 7px; padding: 2px; }
.topo nav { display: flex; gap: .25rem; flex: 1; flex-wrap: wrap; }
.topo nav a { color: #cfe3d6; text-decoration: none; padding: .35rem .7rem; border-radius: 6px; font-size: .92rem; }
.topo nav a.ativo, .topo nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.topo .usuario { font-size: .85rem; color: #cfe3d6; display: flex; gap: .6rem; align-items: center; }
.topo .usuario button { background: transparent; border: 1px solid rgba(255,255,255,.3); color: #fff; padding: .25rem .6rem; border-radius: 6px; cursor: pointer; }
.conexao { width: 8px; height: 8px; border-radius: 50%; background: #e5484d; display: inline-block; }
.conexao.on { background: var(--verde-claro); }

main { padding: 1.2rem; max-width: 1400px; margin: 0 auto; }
.grade { display: grid; gap: 1rem; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); } .g4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .g2, .g3, .g4 { grid-template-columns: 1fr; } }

.cartao { background: var(--branco); border: 1px solid var(--linha); border-radius: var(--raio); box-shadow: var(--sombra); padding: 1rem; }
.cartao > h2 { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }

/* botões e campos */
button, .btn { font: inherit; border-radius: 8px; border: 1px solid var(--linha); background: var(--branco); color: var(--tinta); padding: .5rem .9rem; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: .4rem; justify-content: center; }
button:hover, .btn:hover { border-color: var(--verde-claro); }
button:disabled { opacity: .5; cursor: not-allowed; }
.primario { background: var(--verde); border-color: var(--verde); color: #fff; font-weight: 600; }
.primario:hover { background: var(--verde-escuro); }
.grande { padding: .9rem 1.4rem; font-size: 1.1rem; }
.perigo { color: var(--erro); border-color: #f1c4bf; }
.link { border: 0; background: none; color: var(--verde); padding: 0; }
label { display: block; font-size: .85rem; color: var(--tinta-2); margin: .6rem 0 .25rem; font-weight: 600; }
input, select, textarea { font: inherit; width: 100%; padding: .55rem .65rem; border: 1px solid var(--linha); border-radius: 8px; background: #fff; color: var(--tinta); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--verde-claro); outline-offset: 0; border-color: var(--verde-claro); }
input[type=checkbox], input[type=radio] { width: auto; }
.linha-form { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; }
.linha-form > * { flex: 1; min-width: 150px; }

/* tabelas e listas */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .55rem; border-bottom: 1px solid var(--linha); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--tinta-2); font-weight: 600; }
tr:hover td { background: #fafcfa; }

.etiqueta { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: var(--verde-fundo); color: var(--verde-escuro); font-weight: 600; white-space: nowrap; }
.etiqueta.cinza { background: #EEF0EF; color: #4a524e; }
.etiqueta.alerta { background: var(--alerta-fundo); color: var(--alerta); }
.etiqueta.erro { background: var(--erro-fundo); color: var(--erro); }
.etiqueta.azul { background: #E8EAF4; color: var(--azul); }
.etiqueta.ouro { background: #F7F0DF; color: #7A6227; }
.prioridade { background: var(--alerta-fundo); color: var(--alerta); }

.senha { font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: .03em; color: var(--verde-escuro); }
.vazio { padding: 1.5rem; text-align: center; color: var(--tinta-2); }
.abas { display: flex; gap: .25rem; border-bottom: 1px solid var(--linha); margin-bottom: 1rem; flex-wrap: wrap; }
.abas button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: .6rem .9rem; color: var(--tinta-2); }
.abas button.ativo { border-bottom-color: var(--verde); color: var(--verde-escuro); font-weight: 600; }

/* modal */
.modal-fundo { position: fixed; inset: 0; background: rgba(16, 30, 22, .45); display: flex; align-items: flex-start; justify-content: center; padding: 4vh 1rem; z-index: 50; overflow: auto; }
.modal { background: #fff; border-radius: 12px; max-width: 760px; width: 100%; padding: 1.2rem 1.4rem; box-shadow: 0 10px 40px rgba(0,0,0,.2); }
.modal .acoes { display: flex; gap: .5rem; justify-content: flex-end; margin-top: 1rem; flex-wrap: wrap; }

/* avisos */
#toasts { position: fixed; right: 1rem; bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; z-index: 99; }
.toast { background: var(--verde-escuro); color: #fff; padding: .7rem 1rem; border-radius: 8px; box-shadow: var(--sombra); max-width: 420px; white-space: pre-line; }
.toast.erro { background: var(--erro); }
.aviso { padding: .7rem .9rem; border-radius: 8px; background: var(--alerta-fundo); color: var(--alerta); font-size: .9rem; margin: .5rem 0; white-space: pre-line; }
.aviso.info { background: var(--verde-fundo); color: var(--verde-escuro); }
.aviso.erro { background: var(--erro-fundo); color: var(--erro); }

/* lista de exames com check */
.exames-lista { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .35rem .8rem; }
.exame-item { display: flex; gap: .5rem; align-items: flex-start; padding: .35rem .4rem; border-radius: 6px; }
.exame-item:hover { background: var(--verde-fundo); }
.exame-item small { display: block; color: var(--tinta-2); }
.grupo-destino { margin-top: .6rem; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--verde); }

.kpi { font-size: 2rem; font-weight: 700; color: var(--verde-escuro); font-variant-numeric: tabular-nums; }
.kpi-rot { font-size: .82rem; color: var(--tinta-2); }

.status { display: inline-flex; align-items: center; gap: .3rem; font-size: .8rem; padding: .1rem .5rem; border-radius: 6px; background: #EEF0EF; white-space: nowrap; }
.status.aguardando { background: #EEF0EF; color: #4a524e; }
.status.chamado { background: #FFF6D6; color: #7a5a00; }
.status.em_atendimento { background: #E3F0FF; color: #1d4f91; }
.status.concluido, .status.resultado_recebido { background: var(--verde-fundo); color: var(--verde-escuro); }
.status.nao_compareceu, .status.cancelado { background: var(--erro-fundo); color: var(--erro); }
.status.pendente { background: var(--alerta-fundo); color: var(--alerta); }
.status.realizado { background: #E3F0FF; color: #1d4f91; }
.status.ok { background: var(--verde-fundo); color: var(--verde-escuro); }
.status.info { background: #E3F0FF; color: #1d4f91; }
.status.alerta { background: var(--alerta-fundo); color: var(--alerta); }
.status.erro { background: var(--erro-fundo); color: var(--erro); }
