:root {
  --fundo: #04121a;
  --vidro: rgba(6, 24, 33, .82);
  --vidro-forte: rgba(5, 20, 28, .95);
  --borda: rgba(126, 240, 226, .22);
  --texto: #eafaf7;
  --suave: #9ebdb9;
  --ciano: #38f0d8;
  --verde: #6bff8f;
  --ambar: #ffb627;
  --vermelho: #ff6b5e;
  --titulo: 'Chakra Petch', system-ui, sans-serif;
  --corpo: 'Manrope', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--fundo); color: var(--texto); font-family: var(--corpo); font-size: 15px; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ciano); outline-offset: 2px; }
#mapa { position: fixed; inset: 0; background: #000; }
.vinheta { position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 160px rgba(0, 12, 18, .75); }

/* Topo */
.topo { position: fixed; top: 14px; left: 14px; right: 14px; display: flex; align-items: center; gap: 12px; z-index: 5; pointer-events: none; }
.topo > * { pointer-events: auto; }
.marca { display: flex; align-items: center; gap: 12px; padding: 9px 16px 9px 13px; background: var(--vidro); border: 1px solid var(--borda); border-radius: 12px; backdrop-filter: blur(12px); }
.marca strong { display: block; font-family: var(--titulo); font-size: 17px; letter-spacing: .02em; line-height: 1.1; white-space: nowrap; }
.marca small { color: var(--suave); font-size: 12px; }
.marca-sinal { width: 11px; height: 11px; border-radius: 50%; background: var(--ciano); box-shadow: 0 0 0 0 rgba(56, 240, 216, .7); animation: sinal 2.2s infinite; flex: none; }
@keyframes sinal { 70% { box-shadow: 0 0 0 11px rgba(56, 240, 216, 0); } 100% { box-shadow: 0 0 0 0 rgba(56, 240, 216, 0); } }
.busca { position: relative; flex: 1; max-width: 420px; }
.busca input { width: 100%; height: 48px; padding: 0 16px; background: var(--vidro); border: 1px solid var(--borda); border-radius: 12px; backdrop-filter: blur(12px); }
.busca input::placeholder { color: var(--suave); }
.resultados { position: absolute; top: 54px; left: 0; right: 0; margin: 0; padding: 6px; list-style: none; max-height: 340px; overflow: auto; background: var(--vidro-forte); border: 1px solid var(--borda); border-radius: 12px; }
.resultados button { width: 100%; padding: 10px 12px; display: block; text-align: left; background: none; border: 0; border-radius: 8px; }
.resultados button:hover, .resultados button:focus-visible { background: rgba(56, 240, 216, .14); }
.resultados b { font-family: var(--titulo); color: var(--ciano); margin-right: 8px; }
.resultados small { display: block; color: var(--suave); margin-top: 2px; }
.topo-acoes { margin-left: auto; display: flex; gap: 8px; }
.btn-fantasma { min-height: 44px; padding: 0 14px; background: var(--vidro); border: 1px solid var(--borda); border-radius: 10px; backdrop-filter: blur(12px); white-space: nowrap; }
.btn-fantasma:hover { border-color: var(--ciano); color: var(--ciano); }

/* HUD */
.hud { position: fixed; left: 14px; bottom: 28px; width: 300px; padding: 14px 16px; background: var(--vidro); border: 1px solid var(--borda); border-radius: 14px; backdrop-filter: blur(12px); z-index: 4; }
.hud-numeros { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.hud-numeros b { display: block; font-family: var(--titulo); font-size: 28px; line-height: 1; }
.hud-numeros div:nth-child(1) b { color: var(--verde); }
.hud-numeros div:nth-child(2) b { color: var(--ambar); }
.hud-numeros div:nth-child(3) b { color: var(--ciano); }
.hud-numeros span { display: block; font-size: 11.5px; color: var(--suave); margin-top: 4px; line-height: 1.2; }
.barra { height: 4px; margin: 12px 0; background: rgba(255, 255, 255, .1); border-radius: 2px; overflow: hidden; }
.barra i { display: block; height: 100%; width: 0; background: var(--verde); transition: width .6s; }
.legenda { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 10px; font-size: 12px; color: var(--suave); }
.legenda li { display: flex; align-items: center; gap: 7px; }
.legenda i { width: 13px; height: 13px; border-radius: 3px; flex: none; border: 1.5px solid; }
.l-vazio { background: rgba(56, 240, 216, .15); border-color: var(--ciano) !important; }
.l-cad { background: rgba(107, 255, 143, .45); border-color: var(--verde) !important; }
.l-div { background: rgba(255, 182, 39, .5); border-color: var(--ambar) !important; }
.l-comum { background: rgba(255, 255, 255, .14); border-color: #cfd8d6 !important; }
.coord { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%); padding: 6px 12px; font-family: var(--mono); font-size: 12px; color: var(--ciano); background: var(--vidro); border: 1px solid var(--borda); border-radius: 8px; z-index: 3; white-space: nowrap; }

.google-marca { position: fixed; left: 330px; bottom: 6px; display: flex; align-items: center; gap: 10px; padding: 5px 10px; font-size: 11px; color: #fff; text-shadow: 0 0 3px #000; pointer-events: none; z-index: 4; }
.google-marca img { display: block; height: 18px; width: auto; }

/* Painel do lote */
.painel { position: fixed; top: 76px; right: 14px; bottom: 28px; width: 400px; overflow-y: auto; padding: 20px; background: var(--vidro-forte); border: 1px solid var(--borda); border-radius: 16px; z-index: 6; animation: entra .28s ease-out; scrollbar-width: thin; scrollbar-color: rgba(126, 240, 226, .4) transparent; overscroll-behavior: contain; }
@keyframes entra { from { transform: translateX(24px); opacity: 0; } }
.painel-topo { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.painel h2 { margin: 2px 0 0; font-family: var(--titulo); font-size: 28px; line-height: 1.1; }
.sobretitulo { margin: 0; font-family: var(--mono); font-size: 12px; color: var(--ciano); letter-spacing: .08em; text-transform: uppercase; }
.fechar { width: 44px; height: 44px; flex: none; background: none; border: 1px solid var(--borda); border-radius: 10px; font-size: 20px; line-height: 1; }
.fechar:hover { border-color: var(--ciano); color: var(--ciano); }
.ficha { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0; }
.ficha div { padding: 10px 12px; background: rgba(255, 255, 255, .05); border-radius: 10px; }
.ficha .largo { grid-column: 1 / -1; }
.ficha dt, .rotulo { font-size: 11.5px; color: var(--suave); margin: 0 0 3px; }
.ficha dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.ficha dd.mono { font-family: var(--mono); font-size: 13px; font-weight: 400; }
.mapa-link { display: inline-block; padding: 8px 0; color: var(--ciano); font-size: 13.5px; }
.pessoa { margin-top: 12px; padding: 14px; border: 1px solid rgba(107, 255, 143, .4); background: rgba(107, 255, 143, .07); border-radius: 12px; }
.pessoa.parte-b { border-color: rgba(255, 182, 39, .5); background: rgba(255, 182, 39, .07); }
.pessoa h3 { margin: 0; font-size: 19px; font-family: var(--titulo); overflow-wrap: anywhere; }
.pessoa p { margin: 8px 0 0; overflow-wrap: anywhere; }
.selo { display: inline-block; margin-bottom: 6px; padding: 2px 8px; font-size: 11.5px; border-radius: 99px; background: rgba(107, 255, 143, .18); color: var(--verde); }
.parte-b .selo { background: rgba(255, 182, 39, .18); color: var(--ambar); }
.pessoa-acoes { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-linha { min-height: 40px; padding: 0 12px; font-size: 13.5px; background: none; border: 1px solid var(--borda); border-radius: 9px; }
.btn-linha:hover { border-color: var(--ciano); color: var(--ciano); }
.btn-perigo { border-color: rgba(255, 107, 94, .5); color: var(--vermelho); }
.btn-perigo:hover { border-color: var(--vermelho); color: var(--vermelho); }
.btn-principal { width: 100%; min-height: 52px; padding: 0 18px; font-family: var(--titulo); font-size: 17px; font-weight: 700; background: var(--ciano); color: #03211f; border: 0; border-radius: 12px; transition: transform .15s, box-shadow .2s; }
.btn-principal:hover { box-shadow: 0 0 26px rgba(56, 240, 216, .55); transform: translateY(-1px); }
.btn-principal:disabled { opacity: .6; cursor: progress; }
.vazio { margin-top: 12px; padding: 18px; text-align: center; border: 1px dashed var(--ciano); border-radius: 12px; background: rgba(56, 240, 216, .07); }
.vazio p { margin: 0 0 12px; color: var(--suave); }
.btn-dividir { width: 100%; margin-top: 10px; }

/* Formulário */
.grupo { margin-top: 14px; padding: 14px; border: 1px solid var(--borda); border-radius: 12px; }
.grupo.outro { border-color: rgba(255, 182, 39, .55); }
.grupo h3 { margin: 0 0 10px; font-family: var(--titulo); font-size: 16px; }
.grupo.outro h3 { color: var(--ambar); }
.campo { margin-top: 10px; }
.campo label, label.rotulo-campo { display: block; margin-bottom: 4px; font-size: 13px; color: var(--suave); }
.campo input, .campo select { width: 100%; height: 46px; padding: 0 12px; background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .18); border-radius: 9px; }
.campo select option { background: #06202b; }
.marcar { display: flex; align-items: flex-start; gap: 10px; margin-top: 14px; padding: 12px; background: rgba(255, 182, 39, .09); border-radius: 10px; cursor: pointer; }
.marcar.discreto { background: none; padding: 0; margin-top: 10px; font-size: 13.5px; }
.marcar input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--ambar); flex: none; }
.segmentos { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.segmentos button { min-height: 44px; font-size: 13.5px; background: none; border: 1px solid var(--borda); border-radius: 9px; }
.segmentos button[aria-pressed="true"] { background: rgba(255, 182, 39, .2); border-color: var(--ambar); color: var(--ambar); }
.form-acoes { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.erro { min-height: 1.3em; margin: 8px 0 0; color: var(--vermelho); font-size: 13.5px; }
.aviso { margin-top: 12px; padding: 12px; font-size: 13.5px; color: var(--suave); background: rgba(255, 255, 255, .05); border-radius: 10px; }

/* Códigos */
.codigos { margin-top: 14px; padding: 16px; border: 1px solid var(--verde); border-radius: 12px; background: rgba(107, 255, 143, .08); }
.codigos h3 { margin: 0 0 6px; font-family: var(--titulo); color: var(--verde); }
.codigo-item { margin-top: 12px; }
.codigo-item b { display: block; font-family: var(--mono); font-size: 28px; letter-spacing: .14em; color: var(--texto); }

/* Painel admin */
.tabela { width: 100%; margin-top: 12px; border-collapse: collapse; font-size: 13px; }
.tabela th { text-align: left; color: var(--suave); font-weight: 500; padding: 6px 4px; border-bottom: 1px solid var(--borda); }
.tabela td { padding: 8px 4px; border-bottom: 1px solid rgba(255, 255, 255, .07); vertical-align: top; overflow-wrap: anywhere; }
.tabela button { padding: 0; background: none; border: 0; color: var(--ciano); font-family: var(--titulo); font-weight: 600; min-height: 28px; }

/* Rótulos no mapa */
.rot-lote { font-family: var(--titulo); font-weight: 700; font-size: 13px; color: #fff; text-shadow: 0 0 3px #000, 0 1px 3px #000; pointer-events: none; white-space: nowrap; }
.rot-rua { font-family: var(--corpo); font-weight: 600; font-size: 11.5px; letter-spacing: .03em; color: #f6fffd; text-shadow: 0 0 4px #000, 0 0 2px #000; pointer-events: none; white-space: nowrap; }
.rot-comum { font-family: var(--corpo); font-size: 11px; font-weight: 600; color: #fff; text-shadow: 0 0 3px #000; pointer-events: none; white-space: nowrap; }
.rot-lote.com-partes { transform-origin: center; margin-top: -16px; font-size: 11px; opacity: .9; }
.rot-parte { width: 22px; height: 22px; display: grid; place-items: center; font-family: var(--titulo); font-weight: 700; font-size: 13px; color: #1d1300; background: var(--ambar); border-radius: 50%; pointer-events: none; box-shadow: 0 0 0 2px rgba(0, 0, 0, .35); }
.oculto-zoom .rot-parte,
.oculto-zoom .rot-lote, .oculto-zoom .rot-rua, .oculto-zoom .rot-comum { display: none; }
.alvo { width: 76px; height: 76px; pointer-events: none; }
.alvo::before, .alvo::after { content: ''; position: absolute; inset: 0; border: 2px solid var(--ciano); border-radius: 50%; animation: alvo 1.9s ease-out infinite; }
.alvo::after { animation-delay: .95s; }
@keyframes alvo { from { transform: scale(.25); opacity: 1; } to { transform: scale(1); opacity: 0; } }

/* Portão */
.portao { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; overflow-y: auto; padding: 24px 6vw; background: linear-gradient(90deg, rgba(2, 12, 18, .92) 0, rgba(2, 12, 18, .55) 46%, transparent 72%); transition: opacity .7s; }
.portao.saindo { opacity: 0; pointer-events: none; }
body:has(.portao:not(.saindo):not([hidden])) .maplibregl-ctrl-top-right { display: none; }
.portao-caixa { width: 100%; max-width: 410px; }
.portao h1 { margin: 10px 0 12px; font-family: var(--titulo); font-size: clamp(42px, 6vw, 66px); line-height: .98; letter-spacing: -.01em; }
.portao-txt { margin: 0 0 26px; font-size: 17px; color: #cfe7e3; max-width: 34ch; }
.portao label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--suave); }
.portao input { width: 100%; height: 52px; padding: 0 14px; font-family: var(--mono); background: rgba(255, 255, 255, .07); border: 1px solid var(--borda); border-radius: 12px; }
.portao-nota { margin: 14px 0 0; font-size: 12.5px; color: var(--suave); }
.maplibregl-ctrl-top-right { top: 66px; right: 4px; }
.maplibregl-ctrl-attrib { font-size: 10.5px; }
.maplibregl-ctrl-group { background: var(--vidro) !important; }
.maplibregl-ctrl-group button .maplibregl-ctrl-icon { filter: invert(1); }

/* Celular em pé e telas estreitas */
@media (max-width: 820px) and (min-height: 501px), (max-width: 559px) {
  .topo { flex-wrap: wrap; top: max(8px, env(safe-area-inset-top)); left: 8px; right: 8px; gap: 8px; }
  .marca { flex: 1 1 0; min-width: 0; gap: 9px; padding: 0 12px; height: 44px; }
  .marca > div { min-width: 0; }
  .marca strong { font-size: 15px; overflow: hidden; text-overflow: ellipsis; }
  .marca small { display: none; }
  .topo-acoes { flex: none; margin-left: 0; gap: 6px; }
  .btn-fantasma { padding: 0 10px; font-size: 13.5px; }
  .busca { order: 3; flex: 1 0 100%; max-width: none; }
  .busca input { height: 44px; }
  .com-painel .busca { display: none; }
  .com-painel .hud { display: none; }
  .hud { left: 8px; right: 8px; bottom: max(10px, env(safe-area-inset-bottom)); width: auto; padding: 10px 12px; }
  .hud .legenda, .hud .barra { display: none; }
  .hud-numeros b { font-size: 22px; }
  .coord { display: none; }
  .painel { top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 62dvh; border-width: 1px 0 0; border-radius: 18px 18px 0 0; padding: 14px 14px calc(16px + env(safe-area-inset-bottom)); animation-name: sobe; }
  @keyframes sobe { from { transform: translateY(30px); opacity: 0; } }
  .painel h2 { font-size: 23px; }
  .fechar { width: 40px; height: 40px; }
  .ficha { gap: 6px; margin: 10px 0 0; }
  .ficha div { padding: 7px 10px; }
  .ficha div:nth-child(2) { grid-column: 1 / -1; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
  .ficha div:nth-child(3) { display: none; }
  .mapa-link { display: block; padding: 11px 0 3px; }
  .vazio { margin-top: 8px; padding: 12px; }
  .vazio p { margin-bottom: 8px; }
  .portao { background: linear-gradient(180deg, rgba(2, 12, 18, .3), rgba(2, 12, 18, .94) 42%); align-items: flex-end; padding: 20px 16px max(40px, calc(14px + env(safe-area-inset-bottom))); }
  .portao h1 { font-size: 42px; }
  .portao-txt { font-size: 15px; margin-bottom: 18px; }
  .maplibregl-ctrl-top-right { display: none; }
  .maplibregl-ctrl-bottom-right { top: calc(112px + env(safe-area-inset-top)); bottom: auto; right: auto; left: 0; }
  .com-painel .maplibregl-ctrl-bottom-right { top: calc(56px + env(safe-area-inset-top)); }
  .maplibregl-ctrl-attrib { font-size: 9.5px; margin: 0 0 0 8px !important; }
  .google-marca { left: 2px; bottom: auto; top: calc(136px + env(safe-area-inset-top)); flex-wrap: wrap; max-width: 80%; }
}
@media (max-width: 379px) {
  .marca .nome-longo { display: none; }
  .marca-sinal { display: none; }
}
/* Celular deitado: painel ao lado, para o lote continuar à vista */
@media (max-height: 500px) and (min-width: 560px) {
  .topo { top: 8px; left: 8px; right: 8px; gap: 8px; }
  .marca { padding: 0 12px; height: 44px; }
  .marca small { display: none; }
  .marca strong { font-size: 15px; }
  .busca input { height: 44px; }
  .btn-fantasma { padding: 0 10px; font-size: 13.5px; }
  .hud { left: 8px; bottom: 8px; width: 270px; padding: 8px 12px; }
  .hud .legenda, .hud .barra { display: none; }
  .hud-numeros b { font-size: 20px; }
  .coord { display: none; }
  .com-painel .hud { display: none; }
  .painel { top: 0; right: 0; bottom: 0; width: min(340px, 46vw); padding: 12px 14px; border-radius: 14px 0 0 14px; }
  .painel h2 { font-size: 23px; }
  .ficha { gap: 6px; margin: 10px 0 0; }
  .ficha div { padding: 7px 10px; }
  .maplibregl-ctrl-top-right { display: none; }
  .portao { align-items: flex-start; overflow-y: auto; padding: 12px 24px; background: linear-gradient(90deg, rgba(2, 12, 18, .95) 0, rgba(2, 12, 18, .6) 60%, transparent 85%); }
  .portao h1 { font-size: 30px; margin: 4px 0 8px; }
  .portao h1 br { display: none; }
  .portao-txt { display: none; }
  .portao input { height: 46px; }
  .portao-nota { margin-top: 8px; }
  .google-marca { left: 286px; }
  .com-painel .busca, .com-painel .topo-acoes { display: none; }
}
/* Letra menor que 16 px faz o iPhone dar zoom ao tocar no campo e tira a tela do lugar. */
@media (max-width: 820px), (max-height: 500px) {
  input, select { font-size: 16px !important; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
