/* 4MAX Med — visual inspirado no Personal Med (Série 1 Saúde) */
:root {
  --azul: #1f4f9a;
  --azul2: #2f6fc8;
  --azul-claro: #e6eefb;
  --titulo1: #0a3d91;
  --titulo2: #3f82dd;
  --bege: #fffbea;
  --bege2: #f7f0d6;
  --borda: #b9c3d3;
  --texto: #1d2533;
  --cinza: #6b7484;
  --ok: #1f8a3d;
  --erro: #c62828;
  --aviso: #b26a00;
  --raio: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", Tahoma, Verdana, Arial, sans-serif;
  font-size: 13.5px;
  color: var(--texto);
  background: #eef2f8;
}
a { color: var(--azul2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 10px; font-weight: 600; }
h1 { font-size: 20px; color: var(--azul); }
h2 { font-size: 16px; color: var(--azul); }
h3 { font-size: 14px; color: var(--azul); }
small, .muted { color: var(--cinza); }

/* ---------- topo ---------- */
.topo {
  display: flex; align-items: center; gap: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #e9f0fb 100%);
  border-bottom: 1px solid var(--borda);
  padding: 6px 16px; position: sticky; top: 0; z-index: 50;
}
.marca { display: flex; align-items: center; gap: 10px; color: var(--azul); font-weight: 700; }
.marca .logo {
  width: 38px; height: 38px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6fb2ff, #1f4f9a 70%);
  display: grid; place-items: center; color: #fff; font-size: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.3), inset 0 0 0 3px rgba(255,255,255,.55);
}
.marca .nome { line-height: 1.05; }
.marca .nome b { font-size: 17px; display: block; }
.marca .nome span { font-size: 10.5px; font-weight: 500; color: var(--cinza); }
.menu { display: flex; flex-wrap: wrap; gap: 2px; flex: 1; }
.menu a {
  padding: 7px 11px; border-radius: var(--raio); color: var(--texto); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.menu a:hover, .menu a.ativo { background: var(--azul-claro); color: var(--azul); text-decoration: none; }
.menu a.ativo { box-shadow: inset 0 -2px 0 var(--azul2); }
.menu .badge { background: var(--erro); color: #fff; border-radius: 10px; padding: 0 6px; font-size: 11px; }
.usuario-box { text-align: right; font-size: 12px; color: var(--cinza); white-space: nowrap; }
.usuario-box b { color: var(--texto); }

.conteudo { padding: 14px 18px 40px; }
.rodape-suporte {
  position: fixed; bottom: 0; left: 0; right: 0; background: #fff7cf; border-top: 1px solid #e9d98a;
  padding: 3px 14px; font-size: 11.5px; color: #6b5a10; display: flex; gap: 20px; z-index: 40;
}

/* ---------- janela estilo Série 1 ---------- */
.janela {
  background: #fff; border: 1px solid #7f9db9; border-radius: 8px 8px 4px 4px;
  box-shadow: 0 2px 10px rgba(20,40,80,.12); margin-bottom: 14px; overflow: hidden;
}
.janela > .titulo {
  background: linear-gradient(180deg, var(--titulo2) 0%, var(--titulo1) 100%);
  color: #fff; font-weight: 600; padding: 6px 12px; display: flex; align-items: center; gap: 10px;
}
.janela > .titulo .acoes { margin-left: auto; display: flex; gap: 6px; }
.janela > .corpo { padding: 12px 14px; background: var(--bege); }
.janela > .corpo.branco { background: #fff; }

/* ---------- formulários ---------- */
label { display: block; font-size: 12px; color: #33415a; margin-bottom: 2px; }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number],
input[type=email], input[type=search], input[type=color], select, textarea {
  width: 100%; padding: 5px 7px; border: 1px solid #a5b3c8; border-radius: 4px; background: #fff;
  font: inherit; color: inherit;
}
input[type=color] { padding: 1px; height: 30px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #9cc2ff; border-color: var(--azul2); }
textarea { resize: vertical; min-height: 80px; font-family: "Segoe UI", Tahoma, sans-serif; }
textarea.grande { min-height: 340px; font-family: Consolas, "Courier New", monospace; font-size: 13px; }
.obrig::before { content: "* "; color: var(--erro); }
.grade { display: grid; gap: 8px 10px; grid-template-columns: repeat(12, 1fr); }
.c1 { grid-column: span 1; } .c2 { grid-column: span 2; } .c3 { grid-column: span 3; }
.c4 { grid-column: span 4; } .c5 { grid-column: span 5; } .c6 { grid-column: span 6; }
.c7 { grid-column: span 7; } .c8 { grid-column: span 8; } .c9 { grid-column: span 9; }
.c10 { grid-column: span 10; } .c12 { grid-column: span 12; }
.linha { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }
.linha > * { flex: 0 0 auto; }
.check { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; color: var(--texto); margin-right: 12px; }
.check input { width: auto; }
fieldset { border: 1px solid #c9cfda; border-radius: var(--raio); padding: 8px 10px 10px; margin: 0 0 10px; }
legend { color: var(--azul); font-weight: 600; font-size: 12.5px; padding: 0 4px; }

/* ---------- botões ---------- */
.btn, button {
  display: inline-flex; align-items: center; gap: 5px; justify-content: center;
  padding: 6px 13px; border: 1px solid #7f8fa8; border-radius: 4px; cursor: pointer;
  background: linear-gradient(180deg, #ffffff 0%, #e4e9f1 100%); color: var(--texto);
  font: inherit; font-weight: 500; white-space: nowrap; text-decoration: none !important;
}
.btn:hover, button:hover { background: linear-gradient(180deg, #fff 0%, #d6e3f7 100%); border-color: var(--azul2); }
.btn.prim, button.prim { background: linear-gradient(180deg, #4b8fe6, #1f5fae); color: #fff; border-color: #184a8c; }
.btn.prim:hover, button.prim:hover { background: linear-gradient(180deg, #5c9cf0, #2468bd); }
.btn.perigo, button.perigo { color: var(--erro); border-color: #d8a0a0; }
.btn.verde, button.verde { background: linear-gradient(180deg, #4cb86a, #1f8a3d); color: #fff; border-color: #17672e; }
.btn.peq, button.peq { padding: 2px 8px; font-size: 12px; }
.btn:disabled, button:disabled { opacity: .45; cursor: default; }
.barra-botoes { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }
form.inline { display: inline; }

/* ---------- tabelas ---------- */
table.lista { width: 100%; border-collapse: collapse; background: #fff; }
table.lista th {
  text-align: left; font-weight: 600; font-size: 12px; color: #26344d; padding: 5px 7px;
  background: linear-gradient(180deg, #fbfcfe, #e3e8f0); border: 1px solid #c4ccd8; position: sticky; top: 0;
}
table.lista td { padding: 4px 7px; border-bottom: 1px solid #e3e7ee; border-right: 1px solid #f0f2f6; vertical-align: top; }
table.lista tr:hover td { background: #f1f6ff; }
table.lista tr.sel td { background: #316ac5; color: #fff; }
table.lista tr.sel td a { color: #fff; }
table.lista td.num, table.lista th.num { text-align: right; white-space: nowrap; }
.rolagem { max-height: 520px; overflow: auto; border: 1px solid #c4ccd8; }

/* ---------- mensagens ---------- */
.flash { padding: 8px 12px; border-radius: var(--raio); margin-bottom: 10px; border: 1px solid; }
.flash.ok { background: #e7f6ec; border-color: #a6d8b4; color: #17602d; }
.flash.erro { background: #fdecec; border-color: #f0b4b4; color: #8f1d1d; }
.flash.aviso { background: #fff5df; border-color: #f0d08a; color: #7a4b00; }

/* ---------- cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.card {
  background: #fff; border: 1px solid #c9d3e3; border-radius: 8px; padding: 12px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card .rot { font-size: 12px; color: var(--cinza); }
.card .val { font-size: 24px; font-weight: 700; color: var(--azul); margin-top: 2px; }
.card .val.verde { color: var(--ok); } .card .val.vermelho { color: var(--erro); }

/* lançador (tela inicial estilo menu Série 1) */
.lancador { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; margin-bottom: 18px; }
.lancador a {
  background: linear-gradient(180deg, #ffffff, #eaf1fc); border: 1px solid #b7c7e2; border-radius: 10px;
  padding: 16px 12px; text-align: center; color: var(--azul); font-weight: 600; text-decoration: none;
  transition: transform .08s, box-shadow .08s;
}
.lancador a:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(31,79,154,.18); }
.lancador .ico { font-size: 30px; display: block; margin-bottom: 6px; }

/* ---------- agenda ---------- */
.agenda-wrap { display: grid; grid-template-columns: 1fr 260px; gap: 12px; align-items: start; }
.agenda-cab { text-align: center; padding: 4px 0 8px; }
.agenda-cab .dia { font-size: 34px; font-family: Georgia, serif; line-height: 1; color: #1b1b1b; }
.agenda-cab .sub { font-size: 12.5px; color: #333; }
.agenda-barra { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.agenda-barra select { width: auto; }
table.agenda { width: 100%; border-collapse: collapse; background: #fff; table-layout: fixed; }
table.agenda th {
  font-weight: 500; font-size: 12px; text-align: left; padding: 3px 6px; background: #f4f4f0;
  border: 1px solid #b9b9b0;
}
table.agenda td { border: 1px solid #d9d9d0; padding: 2px 6px; height: 23px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 12.5px; }
table.agenda td.hora {
  width: 54px; font-family: Consolas, monospace; font-size: 12px; text-align: center; background: #eef3fb;
  color: #1a3d7c; border-color: #b0c0dc; cursor: pointer;
}
table.agenda tr.vazio td:not(.hora) { cursor: pointer; }
table.agenda tr.vazio:hover td { background: #f3f8ff; }
table.agenda tr.comp td { cursor: pointer; }
table.agenda tr.comp:hover td { filter: brightness(.96); }
table.agenda tr.comp.sel td { background: #316ac5 !important; color: #fff; }
.est { display: inline-block; width: 18px; text-align: center; font-weight: 700; }
.est-marcado { color: #1f4f9a; } .est-confirmado { color: #1f8a3d; } .est-aguardando { color: #b26a00; }
.est-em_atendimento { color: #c62828; } .est-atendido { color: #1f8a3d; } .est-faltou { color: #c62828; }
.est-cancelado { color: #888; }
tr.st-cancelado td, tr.st-faltou td { color: #8a8a8a; text-decoration: line-through; }
tr.st-aguardando td { background: #fff8e1; } tr.st-em_atendimento td { background: #ffecec; }
tr.st-atendido td { background: #eef9f0; } tr.st-confirmado td { background: #f2fbf4; }
tr.outro td { background: repeating-linear-gradient(45deg, #f3f3f3, #f3f3f3 6px, #e9e9e9 6px, #e9e9e9 12px); color: #555; }
.g-ico { font-size: 11px; color: #1a73e8; font-weight: 700; margin-left: 4px; }
.acoes-linha { display: none; gap: 3px; }
tr.comp:hover .acoes-linha { display: inline-flex; }

.mini-cal { background: #fff; border: 1px solid #b9b9b0; border-radius: 4px; padding: 6px; }
.mini-cal .cab { display: flex; gap: 4px; margin-bottom: 4px; }
.mini-cal table { width: 100%; border-collapse: collapse; font-size: 11.5px; }
.mini-cal th { font-weight: 500; color: #555; padding: 2px 0; text-align: center; }
.mini-cal td { text-align: center; padding: 3px 0; cursor: pointer; border-radius: 3px; }
.mini-cal td:hover { background: #dbe8ff; }
.mini-cal td.fora { color: #bbb; }
.mini-cal td.hoje { outline: 1px solid #c62828; }
.mini-cal td.sel { background: #316ac5; color: #fff; }
.mini-cal td.tem { font-weight: 700; color: var(--azul); }
.mini-cal td.tem.sel { color: #fff; }
.relogio { text-align: center; font-size: 12px; margin: 6px 0; color: #444; background: #f4f4f0; border: 1px solid #ccc; padding: 2px; }
.notas textarea { min-height: 180px; background: #fffef2; }

/* diálogo */
dialog {
  border: 1px solid #0a246a; border-radius: 8px 8px 4px 4px; padding: 0; width: min(760px, 96vw);
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
dialog::backdrop { background: rgba(20,30,60,.35); }
dialog .titulo {
  background: linear-gradient(180deg, var(--titulo2), var(--titulo1)); color: #fff; font-weight: 600;
  padding: 7px 12px; display: flex; align-items: center;
}
dialog .titulo button { margin-left: auto; padding: 0 8px; background: #d9534f; color: #fff; border-color: #a33; }
dialog .corpo { padding: 10px 14px 12px; background: #ece9d8; max-height: 82vh; overflow: auto; }
.abas-dlg { display: flex; gap: 2px; margin-bottom: -1px; }
.abas-dlg button { border-radius: 4px 4px 0 0; border-bottom: none; background: #e8e6da; }
.abas-dlg button.ativa { background: #fffbea; font-weight: 600; }
.painel-dlg { border: 1px solid #a9a594; background: #fffbea; padding: 10px; border-radius: 0 4px 4px 4px; }
.estados { display: grid; grid-template-columns: repeat(2, 1fr); gap: 2px 14px; }
.ac-lista {
  position: absolute; background: #fff; border: 1px solid #8aa; z-index: 100; max-height: 240px; overflow: auto;
  box-shadow: 0 4px 12px rgba(0,0,0,.2); min-width: 320px;
}
.ac-lista div { padding: 4px 8px; cursor: pointer; font-size: 12.5px; }
.ac-lista div:hover, .ac-lista div.on { background: #316ac5; color: #fff; }
.ac-lista small { color: inherit; opacity: .75; }
.pos-rel { position: relative; }

/* ---------- prontuário (ficha com abas coloridas) ---------- */
.ficha { display: grid; grid-template-columns: 54px 1fr 150px; gap: 0; align-items: stretch;
  border: 1px solid #0a246a; border-radius: 8px 8px 4px 4px; overflow: hidden; background: #fff;
  box-shadow: 0 3px 14px rgba(20,40,80,.18); }
.ficha-topo {
  grid-column: 1 / -1; background: linear-gradient(180deg, var(--titulo2), var(--titulo1)); color: #fff;
  padding: 6px 12px; display: flex; align-items: center; gap: 14px; font-weight: 600;
}
.ficha-topo .info { font-weight: 400; font-size: 12.5px; opacity: .95; }
.ficha-topo .alerta { background: #ffeb3b; color: #6b2b00; padding: 1px 8px; border-radius: 3px; font-weight: 600; }
.ficha-topo .acoes { margin-left: auto; display: flex; gap: 6px; }
.ficha-topo .acoes .btn { padding: 2px 9px; font-size: 12px; }
.argolas {
  background: linear-gradient(90deg, #e9eef6, #f8fafd); border-right: 1px solid #c8d0de;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px 0; position: relative;
}
.argolas::after {
  content: ""; position: absolute; right: -9px; top: 30px; bottom: 30px; width: 10px;
  background: repeating-linear-gradient(180deg, transparent 0 40px, #7d8794 40px 46px, transparent 46px 80px);
  border-radius: 4px;
}
.argolas a {
  width: 38px; height: 38px; display: grid; place-items: center; border-radius: 8px; font-size: 20px;
  background: #fff; border: 1px solid #c4cfe0; text-decoration: none; position: relative;
}
.argolas a:hover { background: #dbe8ff; }
.argolas a .tip {
  display: none; position: absolute; left: 44px; background: #ffffe1; border: 1px solid #777; color: #000;
  font-size: 11.5px; padding: 1px 6px; white-space: nowrap; z-index: 20;
}
.argolas a:hover .tip { display: block; }
.argolas a.sair { margin-top: auto; background: #d93a2b; color: #fff; border-color: #a02a1f; }
.folha { background: var(--bege); padding: 12px 18px 16px 22px; min-height: 560px; }
.folha h2 { font-size: 17px; color: #0a246a; border-bottom: 1px solid #b6b6a8; padding-bottom: 4px; margin-bottom: 10px; }
.abas-ficha { background: #fff; padding: 6px 4px; display: flex; flex-direction: column; gap: 2px; border-left: 1px solid #ccc; }
.abas-ficha a {
  display: block; padding: 4px 6px; text-align: center; font-size: 12px; color: #4a1400; font-weight: 500;
  border-radius: 3px 8px 8px 3px; border: 1px solid rgba(0,0,0,.12); text-decoration: none;
}
.abas-ficha a:hover { filter: brightness(1.07); text-decoration: none; }
.abas-ficha a.ativa { background: #fffbea !important; color: #000; font-weight: 700; border-left: 3px solid #0a246a;
  box-shadow: -3px 0 0 #fffbea; }
.datas { border: 1px solid #a5b3c8; background: #fff; max-height: 380px; overflow: auto; }
.datas a { display: block; padding: 4px 8px; color: var(--texto); border-bottom: 1px solid #eef; font-size: 12.5px; }
.datas a.sel { background: #316ac5; color: #fff; }
.datas a:hover { background: #e3edff; text-decoration: none; }
.datas a.sel:hover { background: #316ac5; }
.texto-reg {
  white-space: pre-wrap; background: #fff; border: 1px solid #a5b3c8; padding: 10px 12px; min-height: 340px;
  font-family: Consolas, "Courier New", monospace; font-size: 13px; line-height: 1.45;
}
.dois-col { display: grid; grid-template-columns: 170px 1fr; gap: 10px; }
.sinais { background: #fff; border: 1px solid #c9cfda; border-radius: 4px; padding: 8px 10px; margin-bottom: 8px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 11.5px; background: #e5ecf7; color: var(--azul); }
.pill.verde { background: #e2f5e7; color: var(--ok); } .pill.vermelho { background: #fde5e5; color: var(--erro); }
.pill.amarelo { background: #fff2cc; color: #8a5a00; }
.exames-grade { columns: 3 220px; column-gap: 16px; background: #fff; border: 1px solid #a5b3c8; padding: 8px 10px; max-height: 420px; overflow: auto; }
.exames-grade .grupo { break-inside: avoid; margin-bottom: 8px; }
.exames-grade .grupo b { display: block; color: var(--azul); font-size: 12px; margin-bottom: 2px; }
.exames-grade label { font-size: 12.5px; color: var(--texto); display: flex; gap: 5px; align-items: center; margin: 1px 0; }
.exames-grade label input { width: auto; }

/* multimídia */
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.galeria .item { border: 1px solid #c4ccd8; background: #fff; border-radius: 4px; padding: 4px; text-align: center; font-size: 11.5px; }
.galeria img { width: 100%; height: 100px; object-fit: cover; }
.galeria .pdf { height: 100px; display: grid; place-items: center; font-size: 40px; color: #c62828; }
.visor img { max-width: 100%; max-height: 70vh; display: block; margin: auto; }
.visor iframe { width: 100%; height: 70vh; border: 0; }

/* paginação / filtro */
.filtro { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 10px; }
.filtro > div { min-width: 130px; }
.paginacao { display: flex; gap: 4px; margin-top: 10px; }
.abas-top { display: flex; gap: 2px; border-bottom: 1px solid #9fb0c9; margin-bottom: 10px; flex-wrap: wrap; }
.abas-top a { padding: 6px 14px; border: 1px solid transparent; border-bottom: none; border-radius: 6px 6px 0 0; color: var(--texto); }
.abas-top a.ativa { background: #fff; border-color: #9fb0c9; margin-bottom: -1px; font-weight: 600; color: var(--azul); }
.abas-top a:hover { text-decoration: none; background: #e9f0fb; }
.abas-top a.ativa:hover { background: #fff; }

.total-box { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.total-box div { background: #fff; border: 1px solid #c4ccd8; border-radius: 4px; padding: 4px 10px; min-width: 130px; }
.total-box span { display: block; font-size: 11px; color: var(--cinza); }
.total-box b { font-size: 14px; }

.login-wrap { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(ellipse at 30% 20%, #6aa5ec 0%, #2b5fb0 45%, #163a78 100%); }
.login-box { width: 360px; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden; }
.login-box .cab { background: linear-gradient(180deg, #fff, #e6eefb); padding: 24px; text-align: center; border-bottom: 1px solid #c8d4ea; }
.login-box .cab .logo { width: 64px; height: 64px; font-size: 32px; margin: 0 auto 8px; }
.login-box form { padding: 20px 24px 24px; display: grid; gap: 10px; }

@media (max-width: 1000px) {
  .agenda-wrap { grid-template-columns: 1fr; }
  .ficha { grid-template-columns: 44px 1fr; }
  .abas-ficha { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; order: -1; }
  .grade { grid-template-columns: repeat(6, 1fr); }
  .c7,.c8,.c9,.c10,.c12 { grid-column: span 6; }
  .dois-col { grid-template-columns: 1fr; }
}

/* ---------- impressão ---------- */
@media print {
  .topo, .rodape-suporte, .nao-imprimir, .flash { display: none !important; }
  body { background: #fff; }
  .conteudo { padding: 0; }
}
