/* Sistema Abrigo Ana Ribeiro — painel */
:root {
  --azul: #173847; --azul-900: #0f2732; --azul-700: #24505f; --azul-100: #e3ebee;
  --creme: #f1e6c3; --creme-claro: #fbf7ea; --fundo: #f4f1e8;
  --vermelho: #c43a2f; --verde: #2f7d4f; --amarelo: #b7791f;
  --texto: #1d2b31; --suave: #5b6a70; --borda: #dcd6c4;
  --raio: 12px;
  --titulo: "Zilla Slab", Georgia, serif;
  --fonte: "Nunito Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--fonte); color: var(--texto); background: var(--fundo); }
a { color: var(--azul-700); }
h1, h2, h3 { font-family: var(--titulo); color: var(--azul); line-height: 1.2; margin: 0 0 .6rem; }
h2 { font-size: 1.35rem; } h3 { font-size: 1.1rem; }
:focus-visible { outline: 3px solid var(--vermelho); outline-offset: 2px; }

/* Estrutura */
.app { display: flex; min-height: 100vh; }
.lateral {
  width: 250px; flex: none; background: var(--azul); color: var(--creme-claro);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.lateral__marca { display: flex; align-items: center; gap: .7rem; padding: 1.1rem 1.1rem 1rem; color: var(--creme); text-decoration: none; font-family: var(--titulo); line-height: 1.1; border-bottom: 1px solid rgba(241,230,195,.12); }
.lateral__marca strong { font-size: 1.15rem; }
.lateral__nav { padding: .6rem; flex: 1; }
.lateral__nav a { display: flex; align-items: center; gap: .7rem; padding: .6rem .75rem; border-radius: 9px; color: var(--creme-claro); text-decoration: none; font-weight: 600; opacity: .85; }
.lateral__nav a:hover { background: rgba(255,255,255,.07); opacity: 1; }
.lateral__nav a.ativo { background: var(--creme); color: var(--azul); opacity: 1; }
.lateral__nav svg { width: 19px; height: 19px; fill: currentColor; flex: none; }
.lateral__nav .badge { margin-left: auto; background: var(--vermelho); color: #fff; font-size: .72rem; border-radius: 999px; padding: 0 .45rem; }
.lateral__grupo { font-size: .7rem; text-transform: uppercase; letter-spacing: .1em; opacity: .5; margin: 1rem .75rem .3rem; }
.lateral__rodape { padding: .9rem 1.1rem; border-top: 1px solid rgba(241,230,195,.12); display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.lateral__usuario { color: var(--creme-claro); text-decoration: none; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.lateral__usuario strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lateral__usuario small { opacity: .65; }
.lateral__sair { color: var(--creme); font-size: .85rem; }
.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.barra { display: flex; align-items: center; gap: 1rem; padding: .9rem 1.6rem; background: #fff; border-bottom: 1px solid var(--borda); position: sticky; top: 0; z-index: 20; }
.barra h1 { font-size: 1.35rem; margin: 0; flex: 1; min-width: 0; }
.barra__site { font-weight: 700; font-size: .88rem; text-decoration: none; white-space: nowrap; }
.barra__menu { display: none; background: none; border: 0; padding: 6px; cursor: pointer; }
.barra__menu span { display: block; width: 22px; height: 2.5px; background: var(--azul); margin: 4px 0; border-radius: 2px; }
.conteudo { padding: 1.6rem; max-width: 1280px; width: 100%; }
.fundo-menu { display: none; }

@media (max-width: 960px) {
  .lateral { position: fixed; left: 0; top: 0; z-index: 50; transform: translateX(-100%); transition: transform .25s; }
  .lateral.aberta { transform: none; }
  .fundo-menu.visivel { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 40; }
  .barra__menu { display: block; }
  .barra { padding: .8rem 16px; }
  .conteudo { padding: 1.1rem 16px; }
}

/* Componentes */
.painel { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.3rem; margin-bottom: 1.3rem; }
.painel__topo { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .8rem; margin-bottom: 1rem; }
.painel__topo h2 { margin: 0; }
.grade { display: grid; gap: 1.3rem; }
.grade--2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.indicadores { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 1rem; margin-bottom: 1.3rem; }
.indicador { background: #fff; border: 1px solid var(--borda); border-radius: var(--raio); padding: 1.1rem 1.2rem; text-decoration: none; color: inherit; display: block; }
.indicador strong { display: block; font-family: var(--titulo); font-size: 2rem; color: var(--azul); line-height: 1.1; }
.indicador span { color: var(--suave); font-size: .9rem; }
.indicador--alerta strong { color: var(--vermelho); }
a.indicador:hover { border-color: var(--azul-700); }

.btn { display: inline-flex; align-items: center; gap: .4rem; font: 700 .9rem/1 var(--fonte); padding: .7rem 1.05rem; border-radius: 9px; border: 1.5px solid transparent; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn--primario { background: var(--azul); color: var(--creme-claro); }
.btn--primario:hover { background: var(--azul-700); }
.btn--contorno { background: #fff; color: var(--azul); border-color: var(--borda); }
.btn--contorno:hover { border-color: var(--azul); }
.btn--perigo { background: #fff; color: var(--vermelho); border-color: #efc4bf; }
.btn--perigo:hover { background: var(--vermelho); color: #fff; }
.btn--sm { padding: .45rem .7rem; font-size: .82rem; }
.acoes { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
form.inline { display: inline; }

.alerta { padding: .85rem 1rem; border-radius: 10px; margin-bottom: 1.2rem; font-weight: 600; border: 1px solid; }
.alerta--ok { background: #e8f4ec; border-color: #b9dcc5; color: #1f5a36; }
.alerta--erro { background: #fbeceb; border-color: #f0c3be; color: #8a2219; }
.alerta--aviso { background: #fdf5e4; border-color: #ecd6a6; color: #7a5410; }

/* Tabelas */
.tabela-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tabela { width: 100%; border-collapse: collapse; font-size: .92rem; }
.tabela th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); padding: .6rem .7rem; border-bottom: 2px solid var(--borda); white-space: nowrap; }
.tabela td { padding: .65rem .7rem; border-bottom: 1px solid #ece7d8; vertical-align: top; }
.tabela tr:hover td { background: #fcfaf3; }
.tabela .num { text-align: right; white-space: nowrap; }
.vazio { text-align: center; color: var(--suave); padding: 2rem 1rem; }
.etiqueta { display: inline-block; font-size: .75rem; font-weight: 700; padding: .15rem .55rem; border-radius: 999px; background: var(--azul-100); color: var(--azul); white-space: nowrap; }
.etiqueta--verde { background: #e1f1e7; color: #1f5a36; }
.etiqueta--vermelho { background: #fbe3e1; color: #8a2219; }
.etiqueta--cinza { background: #ececec; color: #555; }
.etiqueta--amarelo { background: #fbefd6; color: #7a5410; }
.suave { color: var(--suave); }
.pequeno { font-size: .85rem; }

/* Formulários */
.form { display: grid; gap: 1rem; }
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: .9rem 1rem; }
.campo { display: flex; flex-direction: column; gap: .3rem; }
.campo--largo { grid-column: 1 / -1; }
.campo > span, .rotulo { font-weight: 700; font-size: .85rem; color: var(--azul); }
.campo input, .campo select, .campo textarea, .filtro-barra input, .filtro-barra select {
  font: inherit; padding: .6rem .7rem; border: 1.5px solid var(--borda); border-radius: 8px; background: #fff; width: 100%; color: var(--texto);
}
.campo input:focus, .campo select:focus, .campo textarea:focus { outline: none; border-color: var(--azul-700); box-shadow: 0 0 0 3px var(--azul-100); }
.campo small { color: var(--suave); font-size: .8rem; }
fieldset { border: 1px solid var(--borda); border-radius: 10px; padding: 1rem 1.1rem 1.1rem; margin: 0; }
legend { font-family: var(--titulo); font-weight: 700; color: var(--azul); padding: 0 .4rem; font-size: 1.05rem; }
.opcoes { display: flex; flex-wrap: wrap; gap: .45rem; }
.opcoes label { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .75rem; border: 1.5px solid var(--borda); border-radius: 999px; cursor: pointer; font-size: .9rem; background: #fff; user-select: none; }
.opcoes label:has(input:checked) { background: var(--azul); border-color: var(--azul); color: #fff; }
.opcoes input { accent-color: var(--azul); margin: 0; }
.linha-form { display: grid; grid-template-columns: 150px 1fr; gap: .6rem 1rem; align-items: start; padding: .55rem 0; border-bottom: 1px dashed #e5dfcd; }
.linha-form:last-child { border-bottom: 0; }
.linha-form > .rotulo { padding-top: .45rem; }
@media (max-width: 640px) { .linha-form { grid-template-columns: 1fr; } .linha-form > .rotulo { padding-top: 0; } }
.filtro-barra { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.filtro-barra input, .filtro-barra select { width: auto; min-width: 180px; padding: .55rem .7rem; }
.form-rodape { display: flex; flex-wrap: wrap; gap: .6rem; justify-content: flex-end; padding-top: .4rem; }

/* SSVV */
.ssvv { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .8rem; }
.ssvv__bloco { border: 1px solid var(--borda); border-radius: 10px; padding: .8rem; background: var(--creme-claro); }
.ssvv__bloco .campos { grid-template-columns: repeat(2, 1fr); gap: .6rem; }
.ssvv__bloco .campo span { font-size: .78rem; }
.pa { display: flex; align-items: center; gap: .3rem; }
.pa input { min-width: 0; }

/* Ficha do residente */
.ficha-topo { display: flex; flex-wrap: wrap; gap: 1.2rem; align-items: center; margin-bottom: 1.2rem; }
.avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--creme); color: var(--azul); display: grid; place-items: center; font: 700 1.6rem var(--titulo); overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.ficha-topo h2 { margin: 0; font-size: 1.5rem; }
.abas { display: flex; gap: .3rem; border-bottom: 2px solid var(--borda); margin-bottom: 1.2rem; overflow-x: auto; }
.abas a { padding: .65rem 1rem; text-decoration: none; font-weight: 700; color: var(--suave); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.abas a.ativa { color: var(--azul); border-color: var(--vermelho); }
dl.dados { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: .9rem 1.2rem; margin: 0; }
dl.dados div { border-bottom: 1px solid #eee6d2; padding-bottom: .5rem; }
dl.dados dt { font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--suave); }
dl.dados dd { margin: .1rem 0 0; font-weight: 600; }

/* Ficha de medicação (grade mensal) */
.grade-med { border-collapse: collapse; font-size: .8rem; min-width: 100%; }
.grade-med th, .grade-med td { border: 1px solid #d9d2bd; padding: 0; text-align: center; }
.grade-med thead th { background: var(--azul); color: var(--creme-claro); padding: .35rem .2rem; font-weight: 700; position: sticky; top: 0; }
.grade-med .med { text-align: left; padding: .4rem .55rem; min-width: 170px; background: #fff; position: sticky; left: 0; z-index: 1; }
.grade-med .med strong { display: block; color: var(--azul); }
.grade-med .hora { padding: .3rem .4rem; font-weight: 700; background: var(--creme-claro); white-space: nowrap; }
.grade-med td.dia { width: 30px; min-width: 30px; height: 30px; }
.grade-med th.fds, .grade-med td.fds { background: #f6f2e6; }
.grade-med th.hoje { background: var(--vermelho); }
.grade-med td.hoje { box-shadow: inset 0 0 0 2px var(--vermelho); }
.dose { width: 100%; height: 30px; border: 0; background: transparent; cursor: pointer; font: 800 .95rem var(--fonte); color: var(--azul); padding: 0; }
.dose:hover { background: var(--azul-100); }
.dose[disabled] { cursor: not-allowed; opacity: .35; }
.dose.s-administrado { color: var(--verde); }
.dose.s-recusado { color: var(--vermelho); background: #fbe9e7; }
.dose.s-nao_administrado { color: var(--amarelo); background: #fbf1dc; }
.dose.s-suspenso { color: #777; background: #eee; }
.legenda { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .85rem; color: var(--suave); margin-top: .8rem; }
.legenda b { display: inline-block; min-width: 1.3em; text-align: center; }

/* Painel do dia */
.turno { margin-bottom: 1.2rem; }
.turno h3 { display: flex; align-items: center; gap: .6rem; font-size: 1.25rem; margin-bottom: .6rem; }
.turno h3 .etiqueta { font-family: var(--fonte); }
.doses-lista { display: grid; gap: .45rem; }
.dose-item { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem 1rem; background: #fff; border: 1px solid var(--borda); border-left: 5px solid var(--borda); border-radius: 10px; padding: .6rem .9rem; }
.dose-item.feito { border-left-color: var(--verde); background: #f6fbf8; }
.dose-item.alerta { border-left-color: var(--vermelho); }
.dose-item__info { flex: 1; min-width: 200px; }
.dose-item__info strong { color: var(--azul); }
.dose-item__botoes { display: flex; gap: .35rem; flex-wrap: wrap; }

/* Galeria admin */
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .9rem; }
.foto { background: #fff; border: 1px solid var(--borda); border-radius: 10px; overflow: hidden; }
.foto img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.foto div { padding: .6rem .7rem; font-size: .85rem; display: grid; gap: .4rem; }

/* Login */
.login-pagina { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: radial-gradient(circle at 20% 10%, #e7ddc0, var(--fundo) 55%); }
.login { width: min(400px, 100%); background: #fff; border-radius: 16px; padding: 2rem; box-shadow: 0 20px 50px rgba(15,39,50,.15); border-top: 6px solid var(--azul); }
.login__marca { text-align: center; margin-bottom: 1.4rem; }
.login__marca img { width: 96px; height: 96px; margin: 0 auto .7rem; display: block; }
.login__marca h1 { font-size: 1.5rem; margin: 0; }
.login__marca p { margin: .2rem 0 0; color: var(--suave); font-size: .9rem; }
.login .btn { width: 100%; justify-content: center; padding: .85rem; }

/* Impressão: imprime só o conteúdo, parecido com as fichas em papel */
.so-impressao { display: none; }
@media print {
  @page { margin: 12mm; }
  body { background: #fff; font-size: 11px; }
  .lateral, .barra, .nao-imprimir, .abas, .form-rodape, .alerta, .fundo-menu { display: none !important; }
  .so-impressao { display: block; }
  .conteudo { padding: 0; max-width: none; }
  .painel { border: 0; padding: 0; margin: 0 0 8mm; }
  .tabela-wrap { overflow: visible; }
  .grade-med { font-size: 9px; }
  .grade-med thead th { background: #fff !important; color: #000; position: static; }
  .grade-med td.dia, .dose { height: 18px; width: 18px; min-width: 18px; }
  .dose { background: none !important; color: #000 !important; }
  .grade-med .med { position: static; min-width: 0; }
  .cabecalho-impressao { display: flex; align-items: center; gap: 10px; border-bottom: 2px solid #000; padding-bottom: 6px; margin-bottom: 10px; }
  .cabecalho-impressao img { width: 46px; height: 46px; }
  .cabecalho-impressao h2 { margin: 0; font-size: 15px; color: #000; }
  .cabecalho-impressao p { margin: 0; font-size: 10px; }
  a { color: #000; text-decoration: none; }
}
dl.dados dd { white-space: pre-line; }
[hidden] { display: none !important; }
.grade-med thead th.fds { background: var(--azul-700); }
.grade-med thead th.hoje { background: var(--vermelho); }
fieldset.sem-borda { border: 0; padding: 0; margin: 0; min-width: 0; display: grid; gap: 1rem; }
fieldset.sem-borda[disabled] { opacity: .85; }
.assinatura { margin: 0; font-size: .85rem; color: var(--suave); background: var(--creme-claro); border: 1px solid var(--borda); border-radius: 8px; padding: .5rem .8rem; }
.matriz th, .matriz td { text-align: center; }
.matriz td:first-child, .matriz th:first-child { text-align: left; }
.matriz input { width: 18px; height: 18px; accent-color: var(--azul); }
.matriz .grupo td { background: var(--creme-claro); font-weight: 800; color: var(--azul); text-align: left; }
.json { font: 12px/1.4 ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-word; background: #f7f5ee; border-radius: 6px; padding: .5rem; margin: .3rem 0 0; max-height: 260px; overflow: auto; }
.diff-mudou { background: #fff2c2; }
details.audit summary { cursor: pointer; color: var(--azul-700); font-weight: 700; font-size: .85rem; }
.hash { font: 11px ui-monospace, Menlo, Consolas, monospace; color: var(--suave); word-break: break-all; }
.filtro-barra input[type=checkbox] { min-width: 0; width: auto; padding: 0; }
.filtro-barra label { display: inline-flex; align-items: center; gap: .35rem; }
