:root {
  color-scheme: light;
  --verde: #087C79; --verde-vivo: #049E94; --verde-escuro: #065F5C; --nevoa: #E8F4F3; --nevoa-2: #F2F8F7;
  --laranja: #FF5309; --laranja-forte: #C93A06; --laranja-claro: #FFE9DF; --laranja-texto: #A93204;
  --tinta: #17302E; --tinta-2: #3E5653; --suave: #55706D; --apagado: #8A9A98;
  --linha: #E3ECEA; --linha-2: #EEF3F2; --fundo: #F5F8F8; --papel: #FFFFFF; --azul: #2F4A8A; --azul-claro: #E4ECFA;
  --sombra: 0 1px 2px rgba(23,48,46,.06), 0 10px 28px -6px rgba(23,48,46,.12);
  --fonte: "Figtree", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box }
html, body { height: 100% }
body { margin: 0; background: var(--fundo); color: var(--tinta); font-family: var(--fonte); font-size: 15px; line-height: 1.45 }
button, input, select, textarea { font: inherit; color: inherit }
button { cursor: pointer }
:focus-visible { outline: 2px solid var(--verde-vivo); outline-offset: 2px }
h1, h2, h3 { margin: 0; text-wrap: balance }
h1 { font-size: 24px } h2 { font-size: 17px }
small, .nota { color: var(--suave) }
.nota { font-size: 13px; margin: 6px 0 0 }
.num { font-variant-numeric: tabular-nums }
.carregando { padding: 40px; text-align: center; color: var(--suave) }

/* topo e menu */
.topo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; background: var(--papel); border-bottom: 1px solid var(--linha); padding: 10px 16px; position: sticky; top: 0; z-index: 5 }
.topo-esq, .topo-dir { display: flex; align-items: center; gap: 12px; flex-wrap: wrap }
.logo { height: 34px }
.menu { display: flex; gap: 4px; background: var(--papel); border-bottom: 1px solid var(--linha); padding: 0 12px; overflow-x: auto }
.menu a { padding: 12px 14px; text-decoration: none; color: var(--tinta-2); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; display: flex; align-items: center; gap: 6px }
.menu a.ativo { color: var(--verde); border-bottom-color: var(--verde) }
.pag { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px }
.pag-topo { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; margin-bottom: 16px }
.pag-topo p { margin: 4px 0 0; color: var(--suave) }

/* botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 700; min-height: 40px; text-decoration: none; white-space: nowrap }
.btn.prim { background: var(--verde); color: #fff } .btn.prim:hover { background: var(--verde-escuro) }
.btn.sec { background: var(--papel); color: var(--verde); box-shadow: inset 0 0 0 1.5px var(--verde) } .btn.sec:hover { background: var(--nevoa) }
.btn.alerta { background: var(--laranja-forte); color: #fff }
.btn.zap { background: #1FA855; color: #fff }
.btn.fant { background: transparent; color: var(--tinta-2) } .btn.fant:hover { background: var(--linha-2) }
.btn.mini { min-height: 32px; padding: 6px 11px; font-size: 13px; border-radius: 8px }
.btn:disabled { opacity: .5; cursor: default }
.badge { background: var(--laranja); color: #fff; border-radius: 99px; font-size: 12px; padding: 1px 7px; font-weight: 700 }
label.campo { display: flex; flex-direction: column; gap: 4px; font-weight: 600; font-size: 14px }
label.campo small { font-weight: 400 }
input, select, textarea { border: 1.5px solid var(--linha); border-radius: 10px; padding: 9px 11px; background: #fff; min-height: 42px; width: 100% }
textarea { min-height: 90px; resize: vertical }
input:focus, select:focus, textarea:focus { border-color: var(--verde-vivo); outline: none }
.grade-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px }
.linha { display: flex; flex-wrap: wrap; gap: 8px; align-items: center }
.escolha { display: inline-flex; border: 1.5px solid var(--linha); border-radius: 10px; overflow: hidden }
.escolha button { border: 0; background: #fff; padding: 9px 14px; font-weight: 600 }
.escolha button.on { background: var(--verde); color: #fff }

/* cartões */
.card { background: var(--papel); border: 1px solid var(--linha); border-radius: 14px; padding: 16px; box-shadow: var(--sombra); margin-bottom: 16px }
.card-topo { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px }
.stat { background: var(--papel); border: 1px solid var(--linha); border-radius: 14px; padding: 14px 16px }
.stat span { display: block; color: var(--suave); font-size: 13px; font-weight: 600 }
.stat strong { display: block; font-size: 28px; line-height: 1.2 }
.stat.laranja strong { color: var(--laranja-forte) }
.duas { display: grid; grid-template-columns: 300px 1fr; gap: 16px; align-items: start }
@media (max-width: 860px) { .duas { grid-template-columns: 1fr } }
.vazio { color: var(--apagado); text-align: center; padding: 18px }

/* tabelas e listas */
.tabela-box { overflow-x: auto }
table.tabela { width: 100%; border-collapse: collapse }
.tabela th { text-align: left; font-size: 12px; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; padding: 8px; border-bottom: 1px solid var(--linha) }
.tabela td { padding: 10px 8px; border-bottom: 1px solid var(--linha-2); vertical-align: middle }
.tabela tr.apagada td { opacity: .55 }
.dir { text-align: right }
.pill { display: inline-block; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 700; background: var(--linha-2); color: var(--tinta-2); white-space: nowrap }
.pill.ok { background: #DDF3E6; color: #17663A } .pill.esp { background: var(--laranja-claro); color: var(--laranja-texto) }
.pill.bd { background: var(--azul-claro); color: var(--azul) } .pill.riscado { text-decoration: line-through }
.item { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--linha-2) }
.item:last-child { border-bottom: 0 }
.item span small { display: block }
.prof-item { display: flex; width: 100%; text-align: left; justify-content: space-between; gap: 8px; background: none; border: 0; border-radius: 10px; padding: 9px 10px }
.prof-item:hover { background: var(--nevoa-2) } .prof-item.ativo { background: var(--nevoa) }
.prof-item small { display: block }
.grupo { font-size: 12px; font-weight: 700; color: var(--suave); text-transform: uppercase; letter-spacing: .05em; margin: 12px 10px 4px }

/* calendário */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px }
.cal .sem { text-align: center; font-size: 12px; color: var(--suave); font-weight: 700; padding: 4px 0 }
.cal button { aspect-ratio: 1.15; border: 1px solid var(--linha); background: #fff; border-radius: 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-weight: 700; padding: 2px }
.cal button small { font-size: 11px; font-weight: 600 }
.cal button.atende { background: var(--nevoa); border-color: #BFE0DC }
.cal button.cheio { background: var(--laranja-claro); border-color: #F7C9B4 }
.cal button.hoje { box-shadow: inset 0 0 0 2px var(--verde) }
.cal button.sel { background: var(--verde); color: #fff } .cal button.sel small { color: #E8F4F3 }
.cal button:disabled { background: var(--fundo); color: var(--apagado); border-color: transparent }
.cal .fora { visibility: hidden }
.horas { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px }
.hora { border: 1.5px solid var(--linha); background: #fff; border-radius: 10px; padding: 9px; text-align: left }
.hora b { display: block; font-size: 16px }
.hora.livre { border-color: #9ED3CD } .hora.livre:hover { background: var(--nevoa) }
.hora.ocupado { background: var(--fundo) } .hora.ocupado small { color: var(--tinta-2) }

/* janela (modal) e avisos */
.fundo-modal { position: fixed; inset: 0; background: rgba(23,48,46,.45); display: flex; align-items: flex-start; justify-content: center; padding: 30px 12px; overflow-y: auto; z-index: 20 }
.modal { background: #fff; border-radius: 16px; width: min(640px, 100%); padding: 20px; box-shadow: var(--sombra) }
.modal.largo { width: min(900px, 100%) }
.modal-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; margin-bottom: 14px }
.modal-pe { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 16px }
.toasts { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; z-index: 30 }
.toast { background: var(--tinta); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: var(--sombra) }
.toast.erro { background: var(--laranja-forte) }
.sugestoes { border: 1px solid var(--linha); border-radius: 10px; margin-top: 4px; overflow: hidden }
.sugestoes button { display: block; width: 100%; text-align: left; border: 0; background: #fff; padding: 8px 11px; border-bottom: 1px solid var(--linha-2) }
.sugestoes button:hover { background: var(--nevoa-2) }

/* entrada */
.entrar { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 20px }
.entrar form { background: #fff; border-radius: 18px; padding: 28px; width: min(380px, 100%); box-shadow: var(--sombra); display: flex; flex-direction: column; gap: 14px }
.entrar img { height: 44px; align-self: center }
.erro-txt { color: var(--laranja-forte); font-weight: 600; margin: 0 }
.duas.lado-dir { grid-template-columns: 1fr 360px }
@media (max-width: 860px) { .duas.lado-dir { grid-template-columns: 1fr } }
.item.apagada { opacity: .55 }

/* conversas do WhatsApp */
.conv { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; gap: 16px; align-items: start }
@media (max-width: 860px) { .conv { grid-template-columns: 1fr } .conv.aberta .conv-lista { display: none } .conv:not(.aberta) .conv-painel { display: none } }
.conv-lista .card { padding: 8px }
.conv-grupo { font-size: 12px; font-weight: 800; color: var(--suave); text-transform: uppercase; letter-spacing: .04em; padding: 10px 8px 4px }
.conv-item { display: block; width: 100%; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 9px 10px; margin: 2px 0 }
.conv-item:hover { background: var(--nevoa-2) } .conv-item.sel { background: var(--nevoa) }
.conv-item b { display: flex; justify-content: space-between; gap: 8px; align-items: center }
.conv-item small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis }
.conv-item .res { color: var(--laranja-texto); font-weight: 600 }
.conv-item.urg { box-shadow: inset 3px 0 0 var(--laranja-forte) }
.ponto { width: 9px; height: 9px; border-radius: 50%; background: var(--laranja); display: inline-block; flex: none }
.chat { display: flex; flex-direction: column; gap: 6px; max-height: 58vh; overflow-y: auto; padding: 12px; background: var(--nevoa-2); border-radius: 12px; margin: 12px 0 }
.bolha { max-width: 82%; padding: 8px 11px; border-radius: 12px; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0,0,0,.05) }
.bolha.ent { align-self: flex-start; background: #fff; border-top-left-radius: 4px }
.bolha.sai { align-self: flex-end; background: #DCF6E7; border-top-right-radius: 4px }
.bolha.sai.rec { background: #D9ECFF }
.bolha small { display: block; font-size: 11px; margin-top: 3px; text-align: right }
.bolha .botoes { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px }
.bolha .botoes button { border: 1px solid var(--verde); color: var(--verde); background: #fff; border-radius: 99px; padding: 4px 10px; font-weight: 700; font-size: 13px }
.bolha .botoes span { border: 1px solid var(--linha); border-radius: 99px; padding: 3px 9px; font-size: 13px; background: #fff }
.responder { display: flex; gap: 8px; align-items: flex-end }
.responder textarea { flex: 1; min-height: 46px; max-height: 160px; resize: vertical; border: 1.5px solid var(--linha); border-radius: 10px; padding: 10px }
.faixa-pre { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; background: var(--laranja-claro); border-radius: 10px; padding: 8px 12px; margin-top: 10px }

/* aviso grande: abriu agenda nova para quem estava na lista de espera */
.aviso-grande { background: var(--laranja-claro); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px }
.aviso-grande h2 { font-size: 22px; color: var(--laranja-texto) }
.aviso-grande p { margin: 6px 0 0; color: var(--tinta-2) }

/* Exames e valores: valor e botões sempre na mesma coluna, mesmo com nome comprido */
.item.ex-item { display: grid; grid-template-columns: minmax(0, 1fr) 110px 230px; gap: 12px; align-items: center }
.ex-valor { text-align: right }
.ex-valor small { display: block }
.ex-acoes { display: flex; gap: 6px; justify-content: flex-end; align-items: center }
@media (max-width: 600px) {
  .item.ex-item { grid-template-columns: minmax(0, 1fr) auto }
  .ex-acoes { grid-column: 1 / -1; justify-content: flex-start }
}

/* ---------- Conversas com a cara do WhatsApp ---------- */
.wa-lista { padding: 0 !important; overflow: hidden }
.wa-busca { margin: 10px; width: calc(100% - 20px); border-radius: 10px; background: #f0f2f5; border: 0; padding: 9px 12px }
.conv-item { display: grid !important; grid-template-columns: 46px minmax(0, 1fr); gap: 10px; align-items: center; border-radius: 0 !important; margin: 0 !important; padding: 10px 12px !important; border-bottom: 1px solid #eef0f1 }
.conv-item.sel { background: #f0f2f5 !important }
.conv-item.urg { box-shadow: inset 4px 0 0 var(--laranja-forte) }
.ci-txt { min-width: 0; display: block }
.conv-item small.novo { color: #25d366; font-weight: 700 }
.conv-item .ult { display: flex !important; align-items: center; gap: 4px }
.conv-item .ponto { background: #25d366; margin-left: auto; width: 10px; height: 10px }
.wa-av { width: 42px; height: 42px; border-radius: 50%; background: #dfe5e7; color: #54656f; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: 15px; flex: none }
.wa-av.urg { background: var(--laranja-claro); color: var(--laranja-texto) }
.conv-grupo { background: #fff; padding: 12px 14px 6px !important }
.card.wa { padding: 0; overflow: hidden; display: flex; flex-direction: column }
.wa-vazio { min-height: 50vh; align-items: center; justify-content: center; background: #f0f2f5 !important; text-align: center; color: #54656f }
.wa-logo { font-size: 46px }
.wa-topo { display: flex; align-items: center; gap: 10px; background: #f0f2f5; padding: 10px 14px; border-bottom: 1px solid #e3e6e8; flex-wrap: wrap }
.wa-quem { flex: 1; min-width: 180px }
.wa-quem small { display: block; color: #54656f }
.wa-extra { padding: 0 12px 6px; background: #fff }
.wa-chat { margin: 0 !important; border-radius: 0 !important; max-height: 60vh; min-height: 300px; padding: 14px 5% !important;
  background-color: #efeae2 !important;
  background-image: radial-gradient(rgba(0, 0, 0, .035) 1px, transparent 1px); background-size: 18px 18px }
.wa-chat .bolha { position: relative; max-width: 72%; padding: 6px 9px 18px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13); font-size: 14.5px; line-height: 1.38 }
.wa-chat .bolha.ent { background: #fff; border-top-left-radius: 0 }
.wa-chat .bolha.sai, .wa-chat .bolha.sai.rec { background: #d9fdd3; border-top-right-radius: 0 }
.wa-chat .bolha small { position: absolute; right: 8px; bottom: 3px; font-size: 11px; color: #667781; margin: 0 }
.wa-chat .bolha .autor { display: block; font-size: 12px; font-weight: 700; color: #0f8a7e; margin-bottom: 2px }
.wa-chat .bolha .botoes a, .wa-chat .bolha .botoes button { border: 1px solid #c8d1d4; color: #027eb5; background: #fff; border-radius: 99px; padding: 4px 10px; font-weight: 700; font-size: 13px; text-decoration: none }
.tq { color: #8696a0; letter-spacing: -3px; margin-left: 2px }
.tq.lido { color: #53bdeb }
.tq.erro { color: var(--laranja-forte); letter-spacing: 0 }
.wa-dia { text-align: center; margin: 8px 0 }
.wa-dia span { background: #fff; color: #54656f; font-size: 12px; padding: 4px 10px; border-radius: 8px; box-shadow: 0 1px .5px rgba(11, 20, 26, .13) }
.wa-rapidas { display: flex; gap: 6px; overflow-x: auto; padding: 8px 12px 0; background: #f0f2f5 }
.wa-rapidas button { flex: none; border: 1px solid #d1d7db; background: #fff; border-radius: 99px; padding: 5px 12px; font-size: 13px; color: #3b4a54 }
.wa-rapidas button:hover { background: #e9edef }
.wa-barra { display: flex; align-items: flex-end; gap: 8px; padding: 8px 12px; background: #f0f2f5 }
.wa-barra textarea { flex: 1; border: 0; border-radius: 10px; padding: 10px 12px; min-height: 42px; max-height: 140px; resize: none; background: #fff; font-size: 15px }
.wa-ic { border: 0; background: transparent; font-size: 22px; width: 42px; height: 42px; border-radius: 50%; color: #54656f; flex: none }
.wa-ic:hover { background: #e3e6e8 }
.wa-ic.enviar { background: #00a884; color: #fff; font-size: 18px }
.wa-ic.enviar:hover { background: #008f72 }
.wa-barra.gravando { align-items: center }
.wa-rec { flex: 1; color: #3b4a54 }
.ponto-rec { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #e53935; animation: pisca 1s infinite }
@keyframes pisca { 50% { opacity: .2 } }
.wa-anexo { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: #f0f2f5; border-top: 1px solid #e3e6e8; flex-wrap: wrap }
.wa-anexo img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px }
.wa-doc { font-size: 40px }
.wa-anexo-txt { flex: 1; min-width: 180px }
.wa-anexo-txt small { display: block; color: #667781 }
.wa-anexo-txt input { margin-top: 6px; width: 100%; border-radius: 8px; border: 1px solid #d1d7db; padding: 6px 10px }
.wa-nota { padding: 0 12px 10px; background: #f0f2f5; margin: 0 }
