:root {
  --bg: #f4f6f5;
  --painel: #ffffff;
  --texto: #1f2523;
  --suave: #66706c;
  --linha: #dfe4e2;
  --primaria: #0479b5;
  --primaria-txt: #ffffff;
  --primaria-suave: #e4f1f9;
  --ok: #1a7300; --ok-bg: #e3f3dc;
  --warn: #b45309; --warn-bg: #fef3c7;
  --bad: #b91c1c; --bad-bg: #fee2e2;
  --info: #1d4ed8; --info-bg: #dbeafe;
  --neutral: #475569; --neutral-bg: #e2e8f0;
  --sombra: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --raio: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --painel: #1b201e; --texto: #e7ece9; --suave: #9aa59f; --linha: #2c3430;
    --primaria: #4cb3e6; --primaria-txt: #04223a; --primaria-suave: #10283a;
    --ok: #4ade80; --ok-bg: #133020; --warn: #fbbf24; --warn-bg: #3a2c0b; --bad: #f87171; --bad-bg: #3b1515;
    --info: #93c5fd; --info-bg: #172a4a; --neutral: #cbd5e1; --neutral-bg: #2a3240;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121614; --painel: #1b201e; --texto: #e7ece9; --suave: #9aa59f; --linha: #2c3430;
  --primaria: #4cb3e6; --primaria-txt: #04223a; --primaria-suave: #10283a;
  --ok: #4ade80; --ok-bg: #133020; --warn: #fbbf24; --warn-bg: #3a2c0b; --bad: #f87171; --bad-bg: #3b1515;
  --info: #93c5fd; --info-bg: #172a4a; --neutral: #cbd5e1; --neutral-bg: #2a3240;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--texto); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
a { color: var(--primaria); }
h1, h2 { margin: 0; }
h2 { font-size: 1rem; margin-bottom: .75rem; }
.carregando { padding: 2rem; text-align: center; color: var(--suave); }

/* topo */
.topo { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: .6rem; padding: .6rem 16px; padding-top: max(.6rem, env(safe-area-inset-top)); background: var(--primaria); color: var(--primaria-txt); }
.topo h1 { font-size: 1.05rem; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topo a { color: inherit; text-decoration: none; }
.topo-acoes { display: flex; gap: .4rem; align-items: center; }
.marca { font-size: 1.3rem; }
.btn-icone { background: transparent; border: 0; color: inherit; font-size: 1.3rem; width: 2.2rem; height: 2.2rem; border-radius: 50%; cursor: pointer; display: inline-grid; place-items: center; }
.btn-icone:hover { background: rgba(127,127,127,.18); }
.girando { animation: gira 1s linear infinite; }
@keyframes gira { to { transform: rotate(360deg); } }
.chip-usuario { font-size: .78rem; background: rgba(255,255,255,.18); padding: .3rem .65rem; border-radius: 99px; white-space: nowrap; max-width: 46vw; overflow: hidden; text-overflow: ellipsis; }

/* layout */
.conteudo { padding: 16px; max-width: 1100px; margin: 0 auto; padding-bottom: 6rem; }
.estreito { max-width: 760px; }
.painel { background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); padding: 1rem; margin-bottom: .9rem; box-shadow: var(--sombra); }
.aviso { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: .7rem .9rem; margin: .6rem 0; font-size: .92rem; }
.aviso.erro { background: var(--bad-bg); color: var(--bad); }
.vazio { color: var(--suave); text-align: center; padding: 1rem 0; }
.ajuda { color: var(--suave); font-size: .88rem; margin-top: 0; }

/* lista */
.barra-lista { display: flex; flex-wrap: wrap; gap: .6rem; margin-bottom: .9rem; }
.abas { display: flex; gap: .3rem; overflow-x: auto; flex: 1 1 auto; scrollbar-width: none; }
.aba { border: 1px solid var(--linha); background: var(--painel); color: var(--texto); padding: .45rem .8rem; border-radius: 99px; cursor: pointer; white-space: nowrap; font: inherit; font-size: .9rem; }
.aba span { color: var(--suave); font-size: .8rem; margin-left: .2rem; }
.aba.on { background: var(--primaria); color: var(--primaria-txt); border-color: var(--primaria); }
.aba.on span { color: inherit; opacity: .8; }
#busca { flex: 1 1 240px; min-width: 0; }
.cards { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.card { display: block; background: var(--painel); border: 1px solid var(--linha); border-radius: var(--raio); padding: .85rem 1rem; color: inherit; text-decoration: none; box-shadow: var(--sombra); }
.card:hover { border-color: var(--primaria); }
.card-l1 { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; }
.card-l2 { color: var(--suave); font-size: .9rem; margin: .2rem 0 .45rem; }
.card-l3 { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .8rem; color: var(--suave); }
.card-l3 a { text-decoration: none; }
.alerta-mini { color: var(--warn); font-weight: 600; }
.pendente-sync { color: var(--info); }
.badge { font-size: .72rem; font-weight: 600; padding: .18rem .55rem; border-radius: 99px; white-space: nowrap; }
.badge.neutral { background: var(--neutral-bg); color: var(--neutral); }
.badge.info { background: var(--info-bg); color: var(--info); }
.badge.warn { background: var(--warn-bg); color: var(--warn); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.bad { background: var(--bad-bg); color: var(--bad); }
/* fica acima do selo "Powered by Netlify" do canto inferior direito */
.fab { position: fixed; right: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 64px); background: var(--primaria); color: var(--primaria-txt); text-decoration: none; padding: .85rem 1.2rem; border-radius: 99px; font-weight: 600; box-shadow: 0 4px 14px rgba(0,0,0,.2); }

/* formulários */
.campo { display: flex; flex-direction: column; gap: .3rem; margin-bottom: .85rem; min-width: 0; }
.campo > span, .rot-campo { font-size: .86rem; color: var(--suave); }
.rot-campo b { color: var(--texto); }
.req { color: var(--bad); font-style: normal; }
input, textarea, select { font: inherit; color: var(--texto); background: var(--painel); border: 1px solid var(--linha); border-radius: 9px; padding: .6rem .7rem; width: 100%; min-width: 0; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--primaria); outline-offset: -1px; border-color: transparent; }
input:disabled, textarea:disabled, select:disabled { opacity: .8; }
textarea { resize: vertical; }
.duas { display: grid; grid-template-columns: 1fr; gap: 0 .8rem; }
.tres { display: grid; grid-template-columns: 1fr 4.5rem 7rem; gap: 0 .8rem; }
@media (min-width: 560px) { .duas { grid-template-columns: 1fr 1fr; } .duas .cheio { grid-column: 1 / -1; } }
.acoes { display: flex; gap: .6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: .4rem; }
.acoes.fixas { position: sticky; bottom: 0; background: linear-gradient(transparent, var(--bg) 35%); padding: 1.2rem 0 max(.8rem, env(safe-area-inset-bottom)); }
.btn { font: inherit; font-weight: 600; font-size: .92rem; border: 1px solid var(--linha); background: var(--painel); color: var(--texto); padding: .65rem 1rem; border-radius: 10px; cursor: pointer; }
.btn:hover { border-color: var(--primaria); }
.btn.primario { background: var(--primaria); color: var(--primaria-txt); border-color: var(--primaria); }
.btn.perigo { color: var(--bad); }
.btn.ok { background: #1a7300; color: #fff; border-color: var(--ok); }
.btn.alerta { color: var(--warn); border-color: var(--warn); }
.btn.largo { width: 100%; margin-top: .5rem; }
.btn:disabled { opacity: .6; cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: .4rem; }
.chip { font: inherit; font-size: .9rem; border: 1px solid var(--linha); background: var(--painel); color: var(--texto); padding: .5rem .85rem; border-radius: 99px; cursor: pointer; }
.chip.on { background: var(--primaria-suave); border-color: var(--primaria); color: var(--primaria); font-weight: 600; }
.chip:disabled { cursor: default; }
.chip:disabled:not(.on) { opacity: .5; }
.outro { margin-top: .45rem; }
.chip-check { position: relative; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { display: inline-block; font-size: .88rem; border: 1px solid var(--linha); padding: .45rem .8rem; border-radius: 99px; cursor: pointer; }
.chip-check input:checked + span { background: var(--primaria-suave); border-color: var(--primaria); color: var(--primaria); font-weight: 600; }
.chip-check input:focus-visible + span { outline: 2px solid var(--primaria); }

/* vistoria do técnico */
.resumo .card-l3 { margin-top: .3rem; font-size: .88rem; }
.checkin { margin-top: .8rem; display: grid; gap: .3rem; font-size: .9rem; }
.rot { display: inline-block; min-width: 5.5rem; color: var(--suave); font-size: .8rem; }
.progresso { margin-top: .8rem; display: flex; align-items: center; gap: .6rem; font-size: .8rem; color: var(--suave); }
.barra { flex: 1; height: 7px; background: var(--linha); border-radius: 99px; overflow: hidden; }
.barra i { display: block; height: 100%; background: var(--primaria); transition: width .3s; }
.secao { padding: 0; }
.secao > summary { list-style: none; display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .9rem 1rem; cursor: pointer; font-weight: 600; }
.secao > summary::-webkit-details-marker { display: none; }
.secao > summary::after { content: '▾'; color: var(--suave); transition: transform .2s; }
.secao[open] > summary::after { transform: rotate(180deg); }
.secao > summary > span:first-child { flex: 1; }
.secao > .campos, .secao > .respostas { padding: 0 1rem 1rem; }
.contador { font-size: .75rem; font-weight: 600; }
.contador.falta { color: var(--warn); }
.contador.ok { color: var(--ok); }

.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: .45rem; }
.foto { position: relative; margin: 0; aspect-ratio: 1; border-radius: 9px; overflow: hidden; background: var(--linha); cursor: zoom-in; }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto .del { position: absolute; top: 3px; right: 3px; width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 1rem; cursor: pointer; line-height: 1; }
.add-foto { aspect-ratio: 1; border: 1.5px dashed var(--linha); border-radius: 9px; background: transparent; color: var(--suave); font: inherit; font-size: 1.4rem; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .1rem; }
.add-foto span { font-size: .72rem; }
.add-foto:hover { border-color: var(--primaria); color: var(--primaria); }

.aguas { display: grid; gap: .6rem; }
.agua { border: 1px solid var(--linha); border-radius: 10px; padding: .6rem; }
.agua-topo { display: flex; gap: .4rem; align-items: center; margin-bottom: .5rem; }
.agua-topo input { font-weight: 600; }
.agua-topo .btn-icone { color: var(--bad); }
.agua-grade { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
@media (min-width: 560px) { .agua-grade { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.agua-grade label { display: flex; flex-direction: column; gap: .2rem; font-size: .75rem; color: var(--suave); }

.assinatura canvas { width: 100%; height: 170px; border: 1.5px dashed var(--linha); border-radius: 10px; background: #fff; touch-action: none; display: block; margin: .4rem 0 .8rem; }
.assinatura.feita img { max-width: 260px; width: 100%; background: #fff; border-radius: 8px; border: 1px solid var(--linha); display: block; margin-bottom: .4rem; }
.assinatura.feita { font-size: .88rem; }
.assinatura.feita .btn { margin-top: .5rem; }

.historico { font-size: .82rem; color: var(--suave); margin: 1rem 0; }
.historico summary { cursor: pointer; }
.historico ul { padding-left: 1rem; }
.historico li span { font-variant-numeric: tabular-nums; }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.9); display: grid; place-items: center; padding: 16px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox .btn-icone { position: absolute; top: 12px; right: 12px; color: #fff; font-size: 1.8rem; }

/* engenharia */
.largo-eng { display: grid; gap: 0 1rem; }
@media (min-width: 960px) {
  .largo-eng { grid-template-columns: minmax(0, 1fr) 380px; align-items: start; }
  .coluna-dir { position: sticky; top: 4rem; max-height: calc(100vh - 5rem); overflow-y: auto; }
}
.mini-grade { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem 1rem; margin: .8rem 0; }
.mini-grade dt { font-size: .75rem; color: var(--suave); }
.mini-grade dd { margin: 0; font-size: .92rem; }
.atencao { background: var(--warn-bg); border-color: transparent; color: var(--warn); }
.atencao h2 { color: var(--warn); }
.atencao ul { margin: 0; padding-left: 1.1rem; }
.atencao li { margin: .2rem 0; }
.relato { white-space: pre-wrap; margin: 0; }
.resp { padding: .55rem 0; border-top: 1px solid var(--linha); }
.resp:first-child { border-top: 0; }
.resp .q { font-size: .84rem; color: var(--suave); }
.resp .q b { color: var(--texto); }
.resp .a { margin-top: .2rem; }
.resp.com-alerta .a { color: var(--warn); font-weight: 600; }
.tab { width: 100%; border-collapse: collapse; font-size: .85rem; }
.tab th, .tab td { text-align: left; padding: .35rem .4rem; border-bottom: 1px solid var(--linha); }
.tab th { color: var(--suave); font-weight: 600; font-size: .75rem; }
.tab tfoot td { font-weight: 600; }
.pareceres { display: grid; gap: .5rem; margin: .4rem 0; }

/* config / login */
.logo-linha { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.logo-linha input { flex: 1; }
.logo-prev { max-height: 48px; max-width: 140px; background: #fff; border-radius: 6px; padding: 4px; }
.login { min-height: 100vh; display: grid; place-items: center; }
.login form { width: 100%; max-width: 380px; }
.login h1 { font-size: 1.3rem; margin-bottom: 1rem; color: var(--primaria); }
.logo-login { display: block; width: 100%; max-width: 280px; margin: 0 auto 1rem; background: #fff; border-radius: 8px; padding: 6px; }
.login .ajuda { display: block; text-align: center; margin-top: 1rem; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 5.5rem; transform: translate(-50%, 20px); opacity: 0; transition: .25s; z-index: 60; background: #1f2523; color: #fff; padding: .7rem 1rem; border-radius: 10px; font-size: .9rem; max-width: calc(100vw - 32px); box-shadow: 0 6px 18px rgba(0,0,0,.25); }
.toast.on { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #1a7300; }
.toast.erro { background: #b91c1c; }
