/* WINLAB Web - visual proximo das janelas MiniGUI do WinLab (Windows) */
:root {
  --face: #f0f0f0;          /* fundo das janelas (BTNFACE) */
  --borda: #adadad;
  --borda-grade: #828790;
  --linha-grade: #e5e5e5;
  --sel: #0078d7;           /* linha selecionada no BROWSE */
  --sel-texto: #ffffff;
  --menu-hover: #cce8ff;
  --menu-hover-borda: #99d1ff;
  --texto: #000000;
  --cinza: #6d6d6d;
  --fonte: "Segoe UI", Tahoma, "MS Sans Serif", Arial, sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 12px/1.35 var(--fonte); color: var(--texto); background: #fff;
  display: grid; grid-template-rows: auto 1fr auto; overflow: hidden; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }

/* ---------- titulo e menu da janela principal ---------- */
.titulo-principal { background: #fff; padding: 5px 10px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; border-bottom: 1px solid #f0f0f0; }
.menubar { display: flex; background: #fff; border-bottom: 1px solid #e6e6e6; padding: 0 2px; position: relative; z-index: 5000; user-select: none; }
/* linha do menu: grupos a esquerda, identificacao do sistema a direita */
.barra-menu { display: flex; align-items: center; background: #fff; border-bottom: 1px solid #e6e6e6; }
.barra-menu .menubar { flex: 0 0 auto; border-bottom: 0; }
.barra-menu .menu-id { flex: 1 1 auto; min-width: 0; text-align: right; padding: 0 10px; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menubar .mgrupo { position: relative; }
.menubar .mgrupo > button { background: transparent; border: 1px solid transparent; padding: 2px 9px 3px; margin: 1px 0; cursor: default; }
.menubar .mgrupo > button:hover, .menubar .mgrupo.aberto > button { background: var(--menu-hover); border-color: var(--menu-hover-borda); }
.menubar .mgrupo > button u { text-decoration: underline; }
.mlista { position: absolute; top: 100%; left: 0; background: #f2f2f2; border: 1px solid #ccc; box-shadow: 2px 2px 4px rgba(0,0,0,.25); padding: 2px; min-width: 220px; display: none; }
.mgrupo.aberto .mlista { display: block; }
.mlista button { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid transparent; padding: 3px 30px 3px 32px; cursor: default; white-space: nowrap; }
.mlista button:hover { background: #91c9f7; border-color: #91c9f7; }
.mlista button:focus { outline: 0; background: #91c9f7; border-color: #91c9f7; }
.mlista hr { border: 0; border-top: 1px solid #ccc; margin: 3px 2px 3px 30px; }
.mlista .vazio { padding: 4px 32px; color: var(--cinza); }

/* ---------- area de trabalho ---------- */
.area { position: relative; overflow: hidden; background: #fff url(img/fundo.jpg) center / cover no-repeat; }

/* ---------- barra de status ---------- */
.statusbar { display: flex; background: var(--face); border-top: 1px solid #d7d7d7; font-size: 18px; }
.statusbar span { padding: 3px 6px; white-space: nowrap; }
.statusbar .st-texto { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.statusbar .st-empresa { border-left: 1px solid #d7d7d7; font-weight: bold; text-align: right; }
.statusbar .st-cel { border-left: 1px solid #d7d7d7; min-width: 70px; text-align: center; }

/* ---------- janelas (DEFINE WINDOW ... CHILD / MODAL) ---------- */
.janela { position: absolute; background: var(--face); border: 1px solid #6f9bd1; box-shadow: 0 0 0 1px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.28);
  display: flex; flex-direction: column; min-width: 280px; max-width: 100%; max-height: 100%; }
.janela.inativa { border-color: #aaa; }
.janela.maximizada { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; }
.jtitulo { display: flex; align-items: center; height: 30px; background: #fff; padding-left: 8px; user-select: none; cursor: default; flex: none; }
.janela.inativa .jtitulo { color: #999; }
.jtitulo .jicone { width: 16px; height: 16px; margin-right: 8px; border: 1px solid #7a7a7a; background: linear-gradient(#fff 0 35%, #6b8fc9 35% 50%, #fff 50%); }
.jtitulo .jtexto { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.jtitulo button { width: 46px; height: 30px; border: 0; background: transparent; font-size: 13px; cursor: default; }
.jtitulo button:hover { background: #e5e5e5; }
.jtitulo button.jfechar:hover { background: #e81123; color: #fff; }
.jcorpo { flex: 1; display: flex; flex-direction: column; padding: 10px 14px 0; min-height: 0; overflow: auto; }
.jstatus { flex: none; height: 22px; border-top: 1px solid #d7d7d7; margin-top: 10px; position: relative; }
.jstatus::after { content: ""; position: absolute; right: 2px; bottom: 2px; width: 10px; height: 10px;
  background: radial-gradient(circle, #9b9b9b 1px, transparent 1.5px) 0 0 / 4px 4px; }
.modal-fundo { position: absolute; inset: 0; background: rgba(255,255,255,.01); }

/* ---------- controles ---------- */
.btn { background: #e1e1e1; border: 1px solid var(--borda); padding: 0 10px; min-width: 98px; height: 28px; cursor: default;
  display: inline-flex; align-items: center; justify-content: center; text-align: center; line-height: 1; white-space: nowrap; border-radius: 0; }
.btn.btn-pos { min-width: 0; padding: 0 4px; }
.btn:hover:not(:disabled) { background: #e5f1fb; border-color: #0078d7; }
.btn:active:not(:disabled) { background: #cce4f7; border-color: #005499; }
.btn:focus-visible { outline: 1px dotted #000; outline-offset: -4px; }
.btn:disabled { color: #a0a0a0; background: #ccc; border-color: #bfbfbf; }
.btn-icone { min-width: 32px; width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-icone.btn-pos { min-width: 0; }
.btn-icone img { width: 16px; height: 16px; image-rendering: pixelated; }
input.tb, select.tb, textarea.tb { border: 1px solid #7a7a7a; background: #fff; color: #000; caret-color: #000; padding: 1px 3px; height: 21px; border-radius: 0; }
textarea.tb { height: auto; min-height: 70px; resize: vertical; }
input.tb:focus, select.tb:focus, textarea.tb:focus { outline: none; border-color: #0078d7; }
input.tb[readonly], select.tb:disabled, textarea.tb[readonly] { background: #f0f0f0; color: #6d6d6d; }
.maiusc { text-transform: uppercase; }
input.num { text-align: right; }

fieldset.frame { border: 1px solid #dcdcdc; margin: 0 0 10px; padding: 4px 10px 8px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
fieldset.frame legend { padding: 0 3px; }
fieldset.frame label { display: flex; align-items: center; gap: 8px; }
fieldset.frame .espaco { flex: 1; }

/* ---------- BROWSE ---------- */
.grade { flex: 1; min-height: 160px; border: 1px solid var(--borda-grade); background: #fff; overflow: auto; outline: none; position: relative; }
.grade:focus { border-color: #0078d7; }
.grade table { border-collapse: collapse; table-layout: fixed; min-width: 100%; }
.grade th { position: sticky; top: 0; z-index: 1; background: #fff; font-weight: 400; text-align: left; padding: 3px 6px 4px; border-right: 1px solid #e5e5e5; border-bottom: 1px solid #e5e5e5; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grade th:hover { background: #d9ebf9; }
.grade td { padding: 1px 6px; height: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-right: 1px solid var(--linha-grade); }
.grade td.n { text-align: right; }
.grade td.ed { cursor: text; }
.grade tr.sel td { background: var(--sel); color: var(--sel-texto); }
.grade:not(:focus-within) tr.sel td { background: #cce8ff; color: #000; }
.grade td.editando { padding: 0; }
.grade td.editando input { width: 100%; height: 19px; border: 1px solid #0078d7; padding: 0 4px; font: inherit; color: #000; }
.grade .vazia { padding: 18px; color: var(--cinza); text-align: center; }
.grade .carregando td { color: var(--cinza); text-align: center; }
.rodape-botoes { display: flex; gap: 2px; margin-top: 12px; align-items: center; }
.rodape-botoes .espaco { flex: 1; }

/* ---------- editores ---------- */
.editor-caixa { flex: 1; display: flex; flex-direction: column; min-height: 0; }
textarea.editor-texto { flex: 1; width: 100%; min-height: 200px; resize: none; font: 13px/1.35 "Lucida Console", Consolas, monospace; white-space: pre; overflow: auto; }
.regua { font: 11px/1.4 "Lucida Console", Consolas, monospace; color: #555; background: #fff; border: 1px solid #7a7a7a; border-bottom: 0; padding: 1px 4px; white-space: pre; overflow: hidden; }
.regua + textarea.editor-texto { font-size: 11px; }
.grade td.editavel { padding: 0; }
.grade input.cel { width: 100%; height: 19px; border: 0; padding: 0 6px; font: inherit; background: transparent; color: inherit; }
.grade input.cel:focus { outline: 1px solid #0078d7; outline-offset: -1px; background: #fff; color: #000; }
.grade input.cel.num { text-align: right; }
.grade td .k { display: inline-block; width: 22px; padding-left: 6px; color: inherit; }
.grade td.editavel:has(.k) input { width: calc(100% - 24px); padding-left: 2px; }
.grade:focus-within tr.sel td.editavel input.cel:not(:focus) { color: #fff; }
.valref-info { color: #333; }

/* ---------- Mx_InputWindow ---------- */
.form-linhas { display: grid; grid-template-columns: 90px 1fr; gap: 9px 0; align-items: center; padding: 2px 0 4px; }
.form-linhas > span { padding-right: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.form-linhas > span.chave { font-weight: 600; }
.form-linhas input[type=checkbox] { width: 16px; height: 16px; margin: 0; }
.form-botoes { display: flex; justify-content: center; gap: 12px; margin-top: 14px; }
.form-botoes .esq { margin-right: auto; }
.form-erro { color: #c00; min-height: 16px; margin: 8px 0 0; }

/* ---------- login (Form_acesso) ---------- */
.janela.acesso .jcorpo { background: #0000ff; color: #fff; font-weight: 700; padding: 12px 20px 12px 30px; overflow: hidden; }
.acesso .linha { display: grid; grid-template-columns: 90px 120px; align-items: center; margin-bottom: 12px; }
.acesso .botoes { display: flex; gap: 13px; margin-top: 2px; }
.acesso input.tb { height: 23px; font-weight: 400; }
.acesso input.tb[readonly] { background: #f0f0f0; color: #6d6d6d; border-color: #ccc; cursor: default; }
.acesso input.tb:focus { border-color: #ffd400; box-shadow: 0 0 0 1px #ffd400; }
.acesso .btn { color: #000; font-weight: 400; min-width: 100px; }
.acesso .erro { color: #ffef7a; font-weight: 400; margin: -4px 0 6px; max-width: 210px; }
.acesso .erro:empty { display: none; }

/* ---------- avisos (MsgInfo) ---------- */
.avisos { position: fixed; right: 12px; bottom: 30px; display: grid; gap: 6px; z-index: 9999; }
.aviso { background: #fff; border: 1px solid #888; box-shadow: 2px 2px 6px rgba(0,0,0,.3); padding: 8px 12px; max-width: 360px; }
.aviso.erro { border-color: #c00; color: #a00; }
.aviso.ok { border-color: #2a7a2a; }

/* ---------- telas pequenas ---------- */
@media (max-width: 760px) {
  .titulo-principal { display: none; }
  .barra-menu .menu-id { display: none; }
  .menubar { flex-wrap: wrap; }
  .mlista { position: fixed; left: 4px !important; right: 4px; top: auto; }
  .janela { left: 0 !important; top: 0 !important; width: 100% !important; height: 100% !important; }
  .statusbar .st-texto { display: none; }
  .form-linhas { grid-template-columns: 1fr; gap: 2px; }
  .form-linhas > span { margin-top: 6px; }
  .form-linhas .tb { width: 100% !important; }
  fieldset.frame label { flex: 1 1 100%; }
  fieldset.frame input { flex: 1; width: auto !important; }
}

/* ---------- Cadastro de Pacientes (posicoes do desktop) ---------- */
.jcorpo.pac-corpo { padding: 0; overflow: auto; }
.pac-form { position: relative; width: 795px; height: 565px; flex: none; }
.pac-form .plabel { font-size: 12px; white-space: nowrap; line-height: 15px; }
.pac-form .negrito { font-weight: 700; }
.pac-form .grande { font-size: 13px; }
.pac-form fieldset.pframe { display: block; margin: 0; padding: 0; border: 1px solid #dcdcdc; }
.pac-form fieldset.pframe legend { margin-left: 8px; font-size: 12px; }
.pac-form .pficha { border: 1px solid #a0a0a0; border-right-color: #fff; border-bottom-color: #fff; padding: 2px 6px; font-size: 12px; text-align: right; }
.pac-form .totlbl { font: 12px/15px "Lucida Console", Consolas, monospace; white-space: pre; }
.pac-form input.tb, .pac-form select.tb { font-size: 12px; }
.pac-form .tb.foco, .frame input.tb:focus { background: #ffff00; }
.pac-form .grade { min-height: 0; }
.pac-form .grade td.flg { padding: 0 2px; text-align: center; }
.pac-form .grade td.flg img { width: 16px; height: 16px; vertical-align: middle; }
.grade th.clicavel { cursor: pointer; text-decoration: underline dotted; }
.minusc { text-transform: lowercase; }

.jcorpo.pac-corpo.sem-rolagem { overflow: hidden; }
.pac-form .relogio { white-space: nowrap; }
a.btn { text-decoration: none; color: inherit; }
/* BROWSE do LAUDOS.PRG: grade com edicao na celula */
table.masc { font-family: "Lucida Console", "Courier New", monospace; font-size: 12px; }
table.masc th { position: sticky; top: 0; background: #fff; font: 13px "Lucida Console", "Courier New", monospace; text-align: left; padding: 3px 4px; border-right: 1px solid #e5e5e5; border-bottom: 1px solid #ccc; white-space: pre; z-index: 1; }
table.masc td { padding: 0; border-right: 1px solid #e3e3e3; height: 16px; }
table.masc td.nlin { color: #000; text-align: center; padding: 0 4px; }
table.masc td:first-child.nlin { color: #999; font-size: 10px; }
table.masc input { border: 0 !important; background: transparent !important; box-shadow: none !important; height: 16px !important; padding: 0 3px !important; color: inherit; font: inherit !important; }
table.masc input.num { text-align: right; }
table.masc input:focus { background: #fff !important; color: #000; outline: 1px solid #0078d7; outline-offset: -1px; }
table.masc tr:focus-within td { background: #0078d7; color: #fff; }
table.masc tr.fora td { color: #aaa; }

/* ---- menu Mapas (mapas.js) ---- */
.mapa-quadro { border: 1px solid #dcdcdc; margin: 10px 14px 8px; padding: 14px 16px 10px; display: flex; flex-direction: column; gap: 10px; }
.mapa-quadro.sem-borda { border: 0; }
.mapa-linha { display: flex; align-items: center; gap: 8px; }
.mapa-linha > span:first-child { width: 70px; flex: none; }
.mapa-linha .mapa-a { width: auto; }
.mapa-info { color: var(--cinza, #666); }
.mapa-radios { display: flex; gap: 16px; }
.mapa-radios label { display: flex; align-items: center; gap: 4px; }
.mapa-botoes { display: flex; justify-content: flex-end; gap: 8px; margin: 6px 14px 4px; }
.mapa-topo { margin: 4px 6px 8px; }
.mapa-topo > span:first-child { width: 80px; }
.mapa-grade { min-height: 200px; }
.mapa-grade td .mapa-x { border: 0; background: transparent; cursor: pointer; color: #a00; padding: 0 6px; }
.mapa-rodape { padding: 0 6px 4px; gap: 8px; }
.mapa-res-titulo { margin: 6px 14px; font-weight: 600; }
.mapa-res-grade { display: grid; grid-auto-flow: column; grid-auto-columns: max-content; gap: 6px 26px; margin: 4px 14px; overflow: auto; flex: 1; align-content: start; }
.mapa-res-item { display: flex; align-items: center; gap: 8px; }
.mapa-res-item > span { width: 54px; text-align: right; }

/* ---- Configuracoes (config.js) ---- */
.cfg-quadro { gap: 8px; }
.cfg-linha { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.cfg-item { display: inline-flex; align-items: center; gap: 6px; }
.cfg-txt { flex: 1 1 0; min-width: 0; }
.cfg-txt .tb { min-width: 0; }
.cfg-quadro { margin-bottom: 8px; }
.sen-topo { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; }
.sen-topo label { display: flex; flex-direction: column; gap: 2px; }
.sen-matriz { display: flex; gap: 10px; align-items: flex-start; overflow: auto; max-height: 400px; margin: 0 14px; }
.sen-tab { border-collapse: collapse; font-size: 12px; background: #fff; }
.sen-tab th, .sen-tab td { border: 1px solid #e0e0e0; padding: 1px 4px; text-align: center; white-space: nowrap; }
.sen-tab th:first-child, .sen-tab td:first-child { text-align: left; }
.sen-tab thead th { background: #f0f0f0; }
.idx-resumo { background: #fff; border: 1px solid #dcdcdc; min-height: 90px; max-height: 160px; overflow: auto; margin: 6px 0; padding: 4px 6px; font: 12px/1.3 "Courier New", monospace; white-space: pre-wrap; }
.apoio-topo { display: flex; align-items: center; gap: 8px; padding: 4px 0 8px; }
.apoio-grade { flex: 1; min-height: 0; overflow: auto; border: 1px solid #7a7a7a; background: #fff; }
.apoio-tab { border-collapse: collapse; font-size: 12px; white-space: nowrap; }
.apoio-tab th { position: sticky; top: 0; background: #f0f0f0; border: 1px solid #ddd; padding: 3px 6px; text-align: left; }
.apoio-tab td { border: 1px solid #eee; padding: 1px 6px; }
.apoio-tab tr.apoio-sel td { background: #cce4ff; }
.tiss-form { padding: 14px 18px; display: flex; flex-direction: column; gap: 10px; }
.tiss-lin { display: flex; align-items: center; gap: 8px; }
.tiss-lin > label { width: 90px; text-align: right; }
.tiss-bt { display: flex; gap: 10px; justify-content: center; margin-top: 6px; }
.tiss-res { font-size: 12px; max-height: 120px; overflow: auto; }
.tiss-res .erro { color: #b00020; }
