/* Assistente de Avaliação · PWA 0.1 · estilo "D" (Prancheta de campo + Painel)
   Letras grandes, contraste alto, botões de no mínimo 44-56 px.
   A arrumação muda pela largura: até 759 px = celular (1 coluna);
   760-1199 px = iPad (lista + componente); 1200 px ou mais = PC (blocos + lista + componente). */

:root {
  --bg: #eef1f5; --card: #ffffff; --barra: #0050b3; --texto: #0d1117; --sub: #424a53;
  --linha: #c9ced6; --trilho: #dde2e8; --azul: #007aff; --azul-texto: #0050b3; --tot-bg: #e6f0ff;
  --neg: #b42318; --c3: #a85400; --c4: #c4320a; --sel: #e6f0ff; --foto: #e3e7ec; --pintura: rgba(0,122,255,.32);
  --sombra: 0 8px 30px rgba(0,0,0,.18);
  color-scheme: light;
}
:root[data-tema="escuro"] {
  --bg: #0d1117; --card: #161b22; --barra: #0b4a9e; --texto: #f0f3f6; --sub: #b1bac4;
  --linha: #30363d; --trilho: #30363d; --azul: #2f8bff; --azul-texto: #6cb0ff; --tot-bg: #0f2747;
  --neg: #ff8a80; --c3: #b86200; --c4: #d13438; --sel: #0f2747; --foto: #1c232c; --pintura: rgba(47,139,255,.5);
  --sombra: 0 8px 30px rgba(0,0,0,.6);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root[data-tema="auto"] {
    --bg: #0d1117; --card: #161b22; --barra: #0b4a9e; --texto: #f0f3f6; --sub: #b1bac4;
    --linha: #30363d; --trilho: #30363d; --azul: #2f8bff; --azul-texto: #6cb0ff; --tot-bg: #0f2747;
    --neg: #ff8a80; --c3: #b86200; --c4: #d13438; --sel: #0f2747; --foto: #1c232c; --pintura: rgba(47,139,255,.5);
    --sombra: 0 8px 30px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--texto);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Atkinson Hyperlegible", sans-serif;
  font-size: 17px; line-height: 1.3; -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { flex: none; }
.oculto { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#app { min-height: 100%; display: flex; flex-direction: column; }

/* ---------- barra azul do alto ---------- */
.barra {
  background: var(--barra); color: #fff; display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) calc(10px + env(safe-area-inset-right)) 10px calc(6px + env(safe-area-inset-left));
  position: sticky; top: 0; z-index: 5;
}
.barra .titulo { flex: 1; min-width: 0; }
.barra .titulo b { display: block; font-size: 21px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .titulo small { display: block; font-size: 14px; opacity: .9; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bt-barra {
  min-width: 48px; height: 48px; border: 0; border-radius: 10px; background: none; color: #fff;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 0 8px;
  font-weight: 700; font-size: 15px; text-decoration: none;
}
.bt-barra:hover { background: rgba(255,255,255,.12); }
.bt-barra .rot { display: none; }
@media (min-width: 760px) { .bt-barra .rot { display: inline; } }

/* ---------- botões e campos ---------- */
.bt {
  min-height: 56px; border-radius: 12px; border: 2px solid var(--texto); background: none;
  font-weight: 700; font-size: 17px; display: inline-flex; align-items: center; justify-content: center;
  gap: 8px; padding: 0 16px; text-decoration: none; color: var(--texto);
}
.bt.cheio { background: var(--barra); border-color: var(--barra); color: #fff; }
.bt.azul { border-color: var(--azul); color: var(--azul-texto); }
.bt.tracejado { border: 2px dashed var(--azul); color: var(--azul-texto); }
.bt.perigo { border-color: var(--c4); color: var(--c4); }
.bt.pequeno { min-height: 44px; font-size: 15px; padding: 0 12px; }
.bt:disabled { opacity: .4; cursor: default; }

.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.campo > span { font-size: 14px; font-weight: 700; color: var(--sub); text-transform: uppercase; letter-spacing: .3px; }
.campo input, .campo select, .campo textarea, .entrada {
  min-height: 52px; border-radius: 12px; border: 2px solid var(--linha); background: var(--card);
  padding: 0 12px; font-size: 18px; width: 100%;
}
.campo textarea { padding: 10px 12px; min-height: 84px; resize: vertical; font-size: 17px; }
.campo input:focus, .campo select:focus, .campo textarea:focus, .entrada:focus { outline: none; border-color: var(--azul); }
.campo .invalido, .entrada.invalido { border-color: var(--c4); }
.grade2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
.grade2 .largo { grid-column: 1 / -1; }

/* ---------- tela inicial ---------- */
.inicio { flex: 1; padding: 16px calc(16px + env(safe-area-inset-right)) 100px calc(16px + env(safe-area-inset-left)); display: flex; flex-direction: column; gap: 14px; max-width: 1400px; width: 100%; margin: 0 auto; }
.continuar {
  border-radius: 16px; background: var(--barra); color: #fff; text-decoration: none;
  padding: 14px 14px 14px 16px; display: flex; align-items: center; gap: 12px;
}
.continuar .rotulo { font-size: 13px; font-weight: 700; letter-spacing: .5px; opacity: .9; }
.continuar b { display: block; font-size: 20px; }
.continuar span.det { display: block; font-size: 15px; opacity: .95; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.busca { display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 12px; border-radius: 12px; border: 2px solid var(--linha); background: var(--card); color: var(--sub); }
.busca input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 17px; color: var(--texto); }
.cartoes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr)); gap: 14px; align-items: start; }
.cartao { border-radius: 16px; background: var(--card); border: 1.5px solid var(--linha); overflow: hidden; }
.cartao .topo { display: flex; gap: 12px; align-items: center; padding: 12px 4px 8px 12px; cursor: pointer; }
.cartao .fachada { width: 84px; height: 60px; border-radius: 10px; background: var(--bg); display: flex; align-items: center; justify-content: center; }
.cartao .nome { font-size: 21px; font-weight: 700; word-break: break-word; }
.cartao .pct { font-size: 18px; font-weight: 700; color: var(--azul-texto); margin-left: 6px; }
.cartao .info { font-size: 15px; color: var(--sub); }
.cartao .blocos { padding: 4px 14px 12px 14px; display: flex; flex-direction: column; gap: 8px; cursor: pointer; }
.linha-bloco { display: grid; grid-template-columns: minmax(80px, 116px) 1fr 54px 30px; align-items: center; gap: 8px; font-size: 15px; }
.linha-bloco > span:first-child { color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.trilho { height: 10px; border-radius: 5px; background: var(--trilho); overflow: hidden; }
.trilho > i { display: block; height: 100%; background: var(--azul); }
.num-dir { text-align: right; font-weight: 700; }
.selo-pend { height: 24px; border-radius: 6px; font-size: 14px; font-weight: 700; display: flex; align-items: center; justify-content: center; color: var(--sub); }
.selo-pend.tem { background: var(--c3); color: #fff; }
.cartao .rodape { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-top: 1.5px solid var(--linha); font-size: 15px; }
.quad4 { width: 20px; height: 20px; border-radius: 5px; background: var(--c4); flex: none; }
.vazio-inicio { text-align: center; color: var(--sub); padding: 30px 10px; font-size: 17px; }

/* barra de abas do celular */
.abas {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--card); border-top: 1.5px solid var(--linha); padding: 4px 4px calc(6px + env(safe-area-inset-bottom)) 4px;
}
.abas button { height: 58px; border: 0; background: none; font-size: 13px; font-weight: 700; color: var(--sub); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; }
.abas button.ativa { color: var(--azul-texto); }
@media (min-width: 760px) { .abas { display: none; } .inicio { padding-bottom: 30px; } }
@media (max-width: 759px) { .so-largo { display: none !important; } }

/* ---------- tela da avaliação: blocos | lista | detalhe ---------- */
.tela-av { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.colunas { flex: 1; display: flex; min-height: 0; }
.col-blocos { display: none; }
.col-lista, .col-detalhe { min-width: 0; }
.col-lista { flex: 1; display: flex; flex-direction: column; }
.col-detalhe { flex: 1; display: none; flex-direction: column; background: var(--card); }
.tela-av[data-painel="el"] .col-lista, .tela-av[data-painel="imovel"] .col-lista { display: none; }
.tela-av[data-painel="el"] .col-detalhe, .tela-av[data-painel="imovel"] .col-detalhe { display: flex; }

@media (min-width: 760px) {
  .colunas { height: calc(100vh - 68px); height: calc(100dvh - 68px - env(safe-area-inset-top)); }
  .col-lista, .tela-av[data-painel] .col-lista { display: flex; flex: 0 0 420px; border-right: 1.5px solid var(--linha); overflow-y: auto; }
  .col-detalhe, .tela-av[data-painel] .col-detalhe { display: flex; overflow-y: auto; }
  .so-celular { display: none !important; }
}
@media (min-width: 1200px) {
  .col-blocos { display: flex; flex-direction: column; gap: 4px; flex: 0 0 250px; padding: 14px 10px; background: var(--bg); border-right: 1.5px solid var(--linha); overflow-y: auto; }
  .col-lista, .tela-av[data-painel] .col-lista { flex: 1 1 560px; }
  .col-detalhe, .tela-av[data-painel] .col-detalhe { flex: 0 1 520px; }
  .sel-bloco { display: none !important; }
}

.item-bloco { border: 0; border-radius: 10px; padding: 10px; text-align: left; background: none; display: flex; flex-direction: column; gap: 6px; box-shadow: inset 3px 0 0 transparent; }
.item-bloco.ativo { background: var(--card); box-shadow: inset 4px 0 0 var(--azul); }
.item-bloco .l1 { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; font-size: 16px; }
.item-bloco .l1 span { font-weight: 400; color: var(--sub); }
.item-bloco .l2 { display: flex; align-items: center; gap: 8px; }
.item-bloco .l2 .trilho { flex: 1; height: 6px; }
.item-bloco .l2 .selo-pend { min-width: 24px; height: 20px; font-size: 12px; }
.titulo-col { font-size: 13px; font-weight: 700; color: var(--sub); padding: 4px 10px; letter-spacing: .4px; }

.topo-lista { padding: 12px 14px 8px 14px; display: flex; flex-direction: column; gap: 10px; background: var(--bg); position: sticky; top: 0; z-index: 2; }
.sel-bloco { position: relative; }
.sel-bloco select {
  width: 100%; min-height: 60px; border-radius: 14px; border: 2px solid var(--texto); background: var(--card);
  font-size: 21px; font-weight: 700; padding: 0 44px 0 14px; appearance: none; -webkit-appearance: none;
}
.sel-bloco svg { position: absolute; right: 14px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.filtros { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.filtros::-webkit-scrollbar { display: none; }
.filtro { flex: none; min-height: 44px; padding: 0 12px; border-radius: 22px; border: 2px solid var(--texto); background: none; font-size: 15px; font-weight: 700; }
.filtro.ativo { background: var(--texto); color: var(--bg); }
.bt-imovel { color: var(--texto); text-decoration: none; display: flex; align-items: center; gap: 10px; min-height: 52px; border-radius: 12px; border: 1.5px solid var(--linha); background: var(--card); padding: 0 12px; font-weight: 700; text-align: left; }
.bt-imovel span { flex: 1; }

.lista { padding: 0 14px 30px 14px; display: flex; flex-direction: column; gap: 8px; }
.linha-el {
  min-height: 68px; border-radius: 14px; background: var(--card); border: 1.5px solid var(--linha);
  display: grid; grid-template-columns: 36px minmax(0, 1fr) 48px 44px; align-items: center; gap: 8px;
  padding: 6px 4px 6px 10px; cursor: pointer; text-align: left;
}
.linha-el.sel { border-color: var(--azul); background: var(--sel); box-shadow: inset 4px 0 0 var(--azul); }
.linha-el.ausente { opacity: .5; }
.linha-el .num { font-size: 19px; font-weight: 700; color: var(--sub); text-align: center; }
.linha-el .nome { font-size: 17px; font-weight: 700; line-height: 1.2; }
.linha-el .sub { font-size: 15px; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linha-el .qtd, .linha-el .ano { display: none; }
.linha-el .tx { display: flex; flex-direction: column; min-width: 0; }
.cond { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 21px; font-weight: 700; border: 2px solid var(--linha); }
.cond.vazio { border-style: dashed; color: var(--sub); }
.cond.c3 { background: var(--c3); border-color: var(--c3); color: #fff; }
.cond.c4 { background: var(--c4); border-color: var(--c4); color: #fff; }
.olho { width: 44px; height: 44px; border: 0; background: none; color: var(--sub); display: flex; align-items: center; justify-content: center; border-radius: 10px; }
.olho:hover { background: var(--bg); }

@media (min-width: 1200px) {
  .lista { gap: 0; padding: 0 14px 30px 14px; }
  .cab-tabela { display: grid !important; }
  .linha-el { grid-template-columns: 36px minmax(0, 1.5fr) minmax(0, 1fr) 90px 44px 56px 44px; border-radius: 0; border-width: 0 0 1px 0; min-height: 52px; }
  .linha-el:first-of-type { border-top-width: 0; }
  .linha-el .qtd, .linha-el .ano { display: block; text-align: right; font-size: 15px; }
  .linha-el .ano { color: var(--sub); }
  .linha-el .nome { font-size: 15px; line-height: 1.25; }
  .linha-el .sub { font-size: 14px; }
  .linha-el .tx { display: contents; }
  .cond { width: 34px; height: 34px; font-size: 16px; justify-self: center; }
}
.cab-tabela { display: none; grid-template-columns: 36px minmax(0, 1.5fr) minmax(0, 1fr) 90px 44px 56px 44px; gap: 8px; padding: 8px 4px 8px 10px; font-size: 13px; font-weight: 700; color: var(--sub); border-bottom: 1.5px solid var(--linha); }

/* ---------- detalhe: elemento e componentes ---------- */
.cab-det { display: flex; align-items: flex-start; gap: 6px; padding: 14px 10px 8px 18px; }
.cab-det .t { flex: 1; min-width: 0; }
.cab-det small { display: block; font-size: 15px; color: var(--sub); }
.cab-det h2 { margin: 0; font-size: 23px; line-height: 1.2; }
.bt-icone { width: 48px; height: 48px; border: 0; border-radius: 10px; background: none; color: var(--azul-texto); display: flex; align-items: center; justify-content: center; }
.bt-icone:hover { background: var(--bg); }
.corpo-det { flex: 1; padding: 6px 18px 24px 18px; display: flex; flex-direction: column; gap: 16px; }
.vazio-det { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--sub); padding: 30px; text-align: center; }

.componente { display: flex; flex-direction: column; gap: 14px; }
.componente + .componente { border-top: 2px solid var(--linha); padding-top: 16px; }
.cab-comp { display: flex; align-items: center; justify-content: space-between; font-weight: 700; color: var(--sub); }
.medidas { border-radius: 14px; border: 1.5px solid var(--linha); overflow: hidden; }
.total { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; background: var(--tot-bg); }
.total .r { font-size: 14px; font-weight: 700; color: var(--azul-texto); }
.total .v { font-size: 32px; font-weight: 700; line-height: 1.1; }
.med { border-top: 1px solid var(--linha); padding: 8px 8px 10px 8px; display: grid; grid-template-columns: 48px minmax(0, 1fr) 48px; gap: 6px; align-items: center; }
.med .contas { grid-column: 2 / 4; display: flex; align-items: center; gap: 6px; }
.med .contas .entrada { flex: 1; min-width: 0; text-align: right; }
.med .contas .x { color: var(--sub); font-weight: 700; }
.med .res { min-width: 80px; text-align: right; font-weight: 700; font-size: 18px; }
.med .res.neg { color: var(--neg); }
.sinal { width: 48px; height: 48px; border-radius: 10px; border: 2px solid var(--linha); background: none; font-size: 24px; font-weight: 700; }
.sinal.menos { border-color: var(--neg); color: var(--neg); }
.lixo { width: 48px; height: 48px; border: 0; background: none; color: var(--sub); border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.botoes-med { border-top: 1px solid var(--linha); display: flex; gap: 8px; padding: 8px; flex-wrap: wrap; }
.aviso { padding: 12px 14px; color: var(--sub); border-top: 1px solid var(--linha); }

.conds { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.bt-cond { min-height: 56px; border-radius: 12px; border: 2px solid var(--linha); background: var(--card); display: flex; align-items: center; gap: 10px; padding: 0 12px; text-align: left; font-weight: 700; }
.bt-cond b { font-size: 26px; }
.bt-cond span { font-size: 15px; line-height: 1.1; }
.bt-cond.ativa { background: var(--texto); border-color: var(--texto); color: var(--bg); }
.bt-cond.ativa.c3 { background: var(--c3); border-color: var(--c3); color: #fff; }
.bt-cond.ativa.c4 { background: var(--c4); border-color: var(--c4); color: #fff; }
@media (min-width: 1200px) { .conds { grid-template-columns: repeat(4, minmax(0, 1fr)); } .bt-cond { flex-direction: column; justify-content: center; gap: 0; text-align: center; padding: 4px; } .bt-cond b { font-size: 20px; } .bt-cond span { font-size: 12px; } }

.rodape-det {
  display: flex; align-items: center; gap: 8px; padding: 10px 18px calc(12px + env(safe-area-inset-bottom)) 18px;
  border-top: 1.5px solid var(--linha); background: var(--card); position: sticky; bottom: 0;
}
.rodape-det .quando { flex: 1; font-size: 13px; color: var(--sub); }
@media (max-width: 759px) { .rodape-det { display: grid; grid-template-columns: 1fr 1fr; } .rodape-det .quando { grid-column: 1 / -1; text-align: center; } }

.secao-form { font-size: 19px; font-weight: 700; margin: 8px 0 0 0; padding-top: 10px; border-top: 2px solid var(--linha); }
.secao-form:first-child { border-top: 0; padding-top: 0; }
.nota { border-radius: 12px; padding: 12px 14px; background: var(--tot-bg); font-size: 15px; }

/* ---------- ajustes ---------- */
.ajustes { padding: 16px; max-width: 720px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; padding-bottom: 110px; }
.grupo { border-radius: 16px; background: var(--card); border: 1.5px solid var(--linha); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.grupo h3 { margin: 0; font-size: 18px; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button { min-height: 48px; border-radius: 10px; border: 2px solid var(--linha); background: none; font-weight: 700; }
.seg button.ativo { background: var(--texto); color: var(--bg); border-color: var(--texto); }

/* ---------- janelas (diálogos) ---------- */
dialog {
  border: 0; border-radius: 18px; padding: 0; background: var(--card); color: var(--texto);
  width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 40px); box-shadow: var(--sombra);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg { display: flex; flex-direction: column; max-height: calc(100dvh - 40px); }
.dlg h3 { margin: 0; padding: 18px 18px 6px 18px; font-size: 21px; }
.dlg .conteudo { padding: 8px 18px 12px 18px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; white-space: pre-line; }
.dlg .conteudo.html { white-space: normal; }
.dlg .botoes { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px 18px 18px; justify-content: flex-end; }
.dlg .botoes .bt { flex: 1 1 140px; }
.marcar { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 4px 6px; border-radius: 10px; }
.marcar input { width: 26px; height: 26px; flex: none; accent-color: var(--barra); }
.menu-op { display: flex; flex-direction: column; gap: 8px; }

.aviso-flutuante {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--texto); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700;
  z-index: 50; box-shadow: var(--sombra); max-width: calc(100vw - 32px); text-align: center;
}
@media (min-width: 760px) { .inicio > .bt.tracejado { align-self: flex-start; min-width: 320px; } }
