:root {
  --bg: #ffffff; --fg: #1a1d21; --sub: #5f6670; --line: #e3e6ea; --acc: #0b63ce; --acc-fg: #fff;
  --shadow: 0 2px 10px rgba(0,0,0,.18); --r: 14px;
  --press: #eef1f4; --tile: #f4f6f8; --page: #eef0ee; --fab-fg: #3b4148;
  --aviso-bg: #fff7e0; --aviso-bd: #f0d58a; --aviso-fg: #5c4600; --mark: #ffe58a;
  --veu: rgba(255,255,255,.85); --alca: #d3d7dc;
  color-scheme: light;
}
:root[data-tema="escuro"] {
  --bg: #1d2127; --fg: #e8eaed; --sub: #9aa3ad; --line: #30363e; --acc: #4c9aff; --acc-fg: #0b1320;
  --shadow: 0 2px 12px rgba(0,0,0,.55);
  --press: #2a3038; --tile: #262b32; --page: #15181c; --fab-fg: #d5d9de;
  --aviso-bg: #3a3218; --aviso-bd: #6b5a22; --aviso-fg: #f1dd9c; --mark: #7a6414;
  --veu: rgba(21,24,28,.88); --alca: #454c55;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--page); color: var(--fg);
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
#map { position: absolute; inset: 0; }
.ic { width: 22px; height: 22px; fill: currentColor; flex: none; }
button { font: inherit; color: inherit; }

#topo { position: absolute; top: calc(12px + env(safe-area-inset-top)); left: 10px; right: 10px; z-index: 5; max-width: 560px; }
#busca { display: flex; align-items: center; gap: 6px; background: var(--bg); border-radius: 26px; box-shadow: var(--shadow); padding: 4px 4px 4px 14px; color: var(--sub); }
#q { flex: 1; min-width: 0; border: 0; outline: 0; font-size: 16px; padding: 10px 2px; background: transparent; color: var(--fg); }
#q::-webkit-search-cancel-button { display: none; }
.icbtn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 20px; font-size: 26px; line-height: 1; color: var(--sub); display: grid; place-items: center; flex: none; }
.icbtn:active { background: var(--press); }

#resultados { margin-top: 6px; background: var(--bg); border-radius: var(--r); box-shadow: var(--shadow); max-height: 55vh; overflow-y: auto; }
.res { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.res:last-child { border-bottom: 0; }
.res:active { background: var(--press); }
.res .bola { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.res .txt { flex: 1; min-width: 0; }
.res .n { font-weight: 600; }
.res .d { color: var(--sub); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.res .km { color: var(--sub); font-size: 13px; flex: none; }
.vazio { padding: 14px; color: var(--sub); }
mark { background: var(--mark); color: inherit; border-radius: 2px; }

#aviso { margin-top: 6px; background: var(--aviso-bg); border: 1px solid var(--aviso-bd); color: var(--aviso-fg); border-radius: var(--r); padding: 8px 12px; font-size: 13px; box-shadow: var(--shadow); }
#resultados:not([hidden]) ~ #aviso { display: none; }
#aviso button { border: 0; background: none; color: var(--acc); font-weight: 600; padding: 0 0 0 6px; }

#fabs { position: absolute; right: 12px; bottom: calc(96px + env(safe-area-inset-bottom)); z-index: 4; display: flex; flex-direction: column; gap: 10px; transition: bottom .2s; }
body.fichaAberta #fabs { bottom: calc(var(--fichaH, 260px) + 12px); }
.fab { width: 48px; height: 48px; border-radius: 24px; border: 0; background: var(--bg); color: var(--fab-fg); box-shadow: var(--shadow); display: grid; place-items: center; }
.fab.ativo { color: var(--acc); }
.fab.seguindo { background: var(--acc); color: #fff; }

.sheet { position: absolute; left: 0; right: 0; bottom: 0; z-index: 6; background: var(--bg); border-radius: 18px 18px 0 0; box-shadow: 0 -2px 16px rgba(0,0,0,.2);
  padding: 6px 16px calc(16px + env(safe-area-inset-bottom)); max-height: 75vh; overflow-y: auto; max-width: 620px; margin: 0 auto; }
.alca { width: 40px; height: 4px; border-radius: 2px; background: var(--alca); margin: 2px auto 8px; }
.fichaTopo { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.nome { font-size: 20px; font-weight: 700; word-break: break-all; }
.sub { color: var(--sub); font-size: 13px; }
.grade { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 10px 0; }
.grade div { background: var(--tile); border-radius: 10px; padding: 6px 8px; font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grade b { display: block; font-size: 12px; font-weight: 500; color: var(--sub); }
.coordLinha { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font: 600 16px/1.3 ui-monospace, "Roboto Mono", monospace; margin-bottom: 12px; }
.acoes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn { border: 1px solid var(--line); background: var(--bg); color: var(--fg); border-radius: 12px; padding: 10px 8px; font-weight: 600; font-size: 14px; }
.btn:active { background: var(--press); }
.btn.prim { grid-column: 1 / -1; background: var(--acc); color: var(--acc-fg); border-color: var(--acc); font-size: 16px; padding: 14px; }

.linhaChk { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); }
.linhaChk input { width: 20px; height: 20px; accent-color: var(--acc); }
.linhaChk .bola { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.25); }
.linhaChk .qt { margin-left: auto; color: var(--sub); font-size: 13px; }
.areaSw { width: 18px; height: 14px; border-radius: 3px; background: rgba(211,47,47,.35); border: 1.5px solid #b3261e; flex: none; }
.traco { width: 18px; height: 4px; border-radius: 2px; background: linear-gradient(90deg,#e4572e,#17bebb,#7b2cbf); }
.item { display: block; width: 100%; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: none; padding: 14px 2px; font-size: 16px; }
.item:active { background: var(--press); }
.item { color: var(--fg); }
.linhaChk input:disabled + * { opacity: .5; }
.info { padding: 12px 2px 0; line-height: 1.5; }

#carregando { position: absolute; inset: 0; z-index: 20; background: var(--veu); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: var(--sub); }
#carregando.oculto { display: none; }
.credito { position: absolute; bottom: calc(24px + env(safe-area-inset-bottom)); font-size: 12px; color: var(--sub); }
.spin { width: 36px; height: 36px; border: 4px solid #cfd6de; border-top-color: var(--acc); border-radius: 50%; animation: g 0.9s linear infinite; }
@keyframes g { to { transform: rotate(360deg); } }
#toast { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(90px + env(safe-area-inset-bottom)); z-index: 30; background: #23272c; color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 14px; max-width: 90vw; text-align: center; }
.maplibregl-ctrl-attrib { font-size: 10px; }
:root[data-tema="escuro"] .maplibregl-ctrl-attrib, :root[data-tema="escuro"] .maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(29,33,39,.85); color: #c9ced4; }
:root[data-tema="escuro"] .maplibregl-ctrl-attrib a { color: #c9ced4; }
:root[data-tema="escuro"] .maplibregl-ctrl-attrib-button { filter: invert(1); }
:root[data-tema="escuro"] .maplibregl-ctrl-scale { background: rgba(29,33,39,.8); color: #e8eaed; border-color: #e8eaed; }
.maplibregl-ctrl-bottom-left { bottom: env(safe-area-inset-bottom); }

/* Rodapé fixo com o copyright */
#rodape { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(8px + env(safe-area-inset-bottom)); z-index: 3;
  max-width: calc(100vw - 150px); padding: 3px 10px; border-radius: 12px; background: var(--veu); color: var(--sub);
  font-size: 11px; line-height: 1.3; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  box-shadow: 0 1px 4px rgba(0,0,0,.12); pointer-events: none; }
