:root {
  --paper: #f8f1dc;
  --paper-2: #fffdf6;
  --ink: #3e2f1c;
  --ink-soft: #6d5a3e;
  --terra: #c1614a;
  --verde: #5f8c41;
  --dourado: #d99a2b;
  --linha: rgba(122, 91, 51, 0.18);
  --sombra: 0 10px 30px rgba(62, 47, 28, 0.18);
  --header-h: 76px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--paper);
  color: var(--ink);
  font-family: "Nunito", system-ui, sans-serif;
  overflow: hidden;
}
body { display: flex; flex-direction: column; }

h1, h2, h3, .pin, .chip, .label, button { font-family: "Baloo 2", "Nunito", sans-serif; }

/* ---------------------------------------------------------------- topo */
.topbar {
  position: relative;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 10px 18px;
  background: linear-gradient(180deg, rgba(248, 241, 220, 0.98), rgba(248, 241, 220, 0.92));
  border-bottom: 2px solid var(--linha);
  box-shadow: 0 6px 18px rgba(62, 47, 28, 0.08);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--terra); color: var(--paper-2);
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 22px;
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.15), 0 3px 8px rgba(62,47,28,.25);
}

.brand h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: .2px; }
.brand p { margin: 0; font-size: 12px; color: var(--ink-soft); letter-spacing: .6px; text-transform: uppercase; }

.search { flex: 1 1 220px; min-width: 180px; max-width: 380px; }

.search input {
  width: 100%; padding: 11px 16px;
  border-radius: 999px; border: 2px solid #ddc9a4;
  background: var(--paper-2); color: var(--ink);
  font-size: 14px; font-family: inherit; outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.search input::placeholder { color: #a8916d; }
.search input:focus { border-color: var(--terra); box-shadow: 0 0 0 4px rgba(193, 97, 74, .14); }

.filters { display: flex; gap: 8px; overflow-x: auto; padding: 2px; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 13px; border-radius: 999px;
  border: 2px solid #ddc9a4; background: var(--paper-2);
  color: var(--ink-soft); font-size: 13px; font-weight: 700;
  cursor: pointer; white-space: nowrap; transition: all .16s;
}
.chip:hover { transform: translateY(-1px); border-color: #c4a878; }
.chip.on { color: #fff; border-color: transparent; background: var(--chip, var(--terra)); box-shadow: 0 4px 10px rgba(62,47,28,.2); }

/* ---------------------------------------------------------------- mapa */
.map-wrap { position: relative; flex: 1 1 auto; min-height: 0; overflow: hidden; background: #efe6cb; }

.map-wrap::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 12;
  background-image: url("../public/ruido.png");
  background-size: 128px 128px;
  opacity: .16; mix-blend-mode: multiply;
}

.viewport {
  position: absolute; inset: 0;
  cursor: grab; touch-action: none;
  overflow: hidden;
}
.viewport.dragging { cursor: grabbing; }

.stage { position: absolute; top: 0; left: 0; transform-origin: 0 0; transition: filter .22s ease; }

.map-img { display: block; width: 100%; height: 100%; pointer-events: none; user-select: none; }

.markers { position: absolute; inset: 0; pointer-events: none; z-index: 13; }

.marker {
  position: absolute;
  border: 0; background: none; padding: 0; font: inherit;
  transform: translate(-50%, -100%);
  display: flex; flex-direction: column; align-items: center;
  pointer-events: none; cursor: pointer;
  transition: filter .18s;
}

.marker .pin { pointer-events: auto; }

.pin svg, .chip-ico svg, .ico svg { display: block; }
.pin svg { width: 20px; height: 20px; }
.chip-ico svg { width: 15px; height: 15px; }
.ico svg { width: 17px; height: 17px; }

.pin {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--c, var(--terra));
  border: 3px solid #fffdf6;
  box-shadow: 0 5px 12px rgba(62, 47, 28, .38);
  line-height: 1;
  position: relative;
  transition: transform .16s ease, box-shadow .16s;
}
.pin::after {
  content: ""; position: absolute; bottom: -8px; left: 50%;
  width: 12px; height: 12px; background: inherit;
  border-right: 3px solid #fffdf6; border-bottom: 3px solid #fffdf6;
  transform: translateX(-50%) rotate(45deg);
  border-radius: 0 0 3px 0;
  z-index: -1;
}

.label {
  margin-top: 6px; padding: 3px 9px;
  background: rgba(255, 253, 246, .95);
  border: 1.5px solid rgba(122, 91, 51, .3);
  border-radius: 999px;
  font-size: 11.5px; font-weight: 700; color: var(--ink);
  white-space: nowrap; box-shadow: 0 2px 6px rgba(62,47,28,.16);
  pointer-events: none;
}

.marker:hover .pin, .marker.active .pin { transform: translateY(-3px) scale(1.12); box-shadow: 0 10px 18px rgba(62,47,28,.45); }
.marker:hover .label, .marker.active .label { background: var(--c, var(--terra)); color: #fff; border-color: transparent; }
.marker.dim { opacity: .22; filter: grayscale(.6); pointer-events: none; }
.marker.dim .pin { pointer-events: none; }
.marker:hover, .marker:focus-visible, .marker.active { z-index: 20; }

/* destaque da Comedoria */
.marker.featured .pin { box-shadow: 0 0 0 5px rgba(193, 97, 74, .25), 0 5px 12px rgba(62,47,28,.38); }

/* ---------------------------------------------------------------- controles */
.zoom {
  position: absolute; right: 18px; bottom: 22px; z-index: 15;
  display: flex; flex-direction: column; gap: 8px;
}
.zoom button {
  width: 44px; height: 44px; border-radius: 14px;
  border: 2px solid #ddc9a4; background: var(--paper-2);
  color: var(--ink); font-size: 20px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(62,47,28,.18);
  transition: transform .15s, background .15s;
}
.zoom button:hover { transform: translateY(-2px); background: #fff; }

.list-toggle {
  position: absolute; left: 18px; bottom: 22px; z-index: 15;
  padding: 12px 18px; border-radius: 999px;
  border: 2px solid #ddc9a4; background: var(--paper-2);
  color: var(--ink); font-size: 14px; font-weight: 700; cursor: pointer;
  box-shadow: 0 4px 12px rgba(62,47,28,.18);
}
.list-toggle:hover { transform: translateY(-2px); }

.hint {
  position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 14; padding: 8px 16px; border-radius: 999px;
  background: rgba(62, 47, 28, .78); color: #f8f1dc;
  font-size: 12.5px; letter-spacing: .2px; white-space: nowrap;
  transition: opacity .4s;
}

/* ---------------------------------------------------------------- card hover */
.card {
  position: absolute; z-index: 25; width: 290px;
  transform: translate(-50%, -100%);
  pointer-events: none;
  animation: pop .16s ease-out;
}
.card-body {
  background: var(--paper-2);
  border: 2px solid rgba(122, 91, 51, .22);
  border-radius: 16px; padding: 14px 16px;
  box-shadow: var(--sombra);
  position: relative;
}
.card-body::after {
  content: ""; position: absolute; bottom: -9px; left: 50%; margin-left: -8px;
  width: 16px; height: 16px; background: var(--paper-2);
  border-right: 2px solid rgba(122,91,51,.22); border-bottom: 2px solid rgba(122,91,51,.22);
  transform: rotate(45deg);
}
.card-cat { font-size: 11px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--terra); }
.card h3 { margin: 2px 0 6px; font-size: 19px; }
.card p { margin: 0 0 8px; font-size: 13.5px; line-height: 1.45; color: var(--ink-soft); }
.card-cta { font-size: 12px; font-weight: 700; color: var(--verde); }

@keyframes pop { from { opacity: 0; transform: translate(-50%, -94%) scale(.96); } to { opacity: 1; } }

/* ---------------------------------------------------------------- painel lista */
.panel {
  position: absolute; top: 0; left: 0; bottom: 0; width: 340px; max-width: 88vw;
  z-index: 26; background: var(--paper);
  border-right: 2px solid var(--linha);
  box-shadow: 12px 0 30px rgba(62, 47, 28, .18);
  transform: translateX(-102%);
  transition: transform .28s cubic-bezier(.4, .1, .2, 1);
  display: flex; flex-direction: column;
}
.panel.open { transform: translateX(0); }

.panel-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 10px; }
.panel-head h2 { margin: 0; font-size: 19px; }
.panel-head button {
  width: 34px; height: 34px; border-radius: 50%; border: 2px solid #ddc9a4;
  background: var(--paper-2); font-size: 20px; line-height: 1; cursor: pointer; color: var(--ink);
}

.list { list-style: none; margin: 0; padding: 4px 10px 20px; overflow-y: auto; }

.list li {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 11px 12px; border-radius: 14px; cursor: pointer;
  transition: background .15s, transform .15s;
}
.list li:hover { background: rgba(193, 97, 74, .09); transform: translateX(2px); }
.list .ico {
  width: 34px; height: 34px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 16px;
  background: var(--c); color: #fff; box-shadow: inset 0 -2px 0 rgba(0,0,0,.12);
}
.list .txt strong { display: block; font-family: "Baloo 2", sans-serif; font-size: 15px; }
.list .txt span { font-size: 12.5px; color: var(--ink-soft); line-height: 1.35; display: block; }
.list .empty { padding: 20px 12px; color: var(--ink-soft); font-size: 14px; }

/* ---------------------------------------------------------------- mobile */
@media (max-width: 780px) {
  :root { --header-h: 132px; }
  .topbar { gap: 10px; padding: 10px 12px; }
  .brand h1 { font-size: 17px; }
  .brand p { font-size: 10px; }
  .search { order: 3; flex-basis: 100%; max-width: none; }
  .filters { order: 4; flex-basis: 100%; }
  .hint { display: none; }
  .card { width: 240px; }
  .zoom { bottom: 88px; }
  .list-toggle { bottom: 22px; }
}


/* agrupamento de pontos próximos */
.marker.cluster .pin {
  width: 46px; height: 46px;
  background: #3e2f1c;
  color: #fffdf6;
  font-size: 16px; font-weight: 800;
  box-shadow: 0 0 0 6px rgba(62, 47, 28, .16), 0 6px 14px rgba(62, 47, 28, .4);
}
.marker.cluster .pin::after { border-color: #fffdf6; }
.marker.cluster:hover .pin { transform: translateY(-3px) scale(1.1); }
.marker.cluster .count { font-family: "Baloo 2", sans-serif; }


/* rótulos escondidos no zoom afastado (evita sobreposição) */
.markers.compact .marker .label { display: none; }
.markers.compact .marker.featured .label { display: inline-block; }


/* lista de um agrupamento */
.cluster-list {
  position: absolute; z-index: 27; width: 260px;
  background: var(--paper-2); border: 2px solid rgba(122, 91, 51, .22);
  border-radius: 16px; box-shadow: var(--sombra); padding: 10px 12px 12px;
}
.cluster-list p {
  margin: 0 0 6px; font-family: "Baloo 2", sans-serif; font-size: 12px;
  text-transform: uppercase; letter-spacing: 1px; color: var(--terra); font-weight: 800;
}
.cluster-list ul { list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.cluster-list a {
  display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--ink);
  font-size: 14px; font-weight: 600; padding: 7px 8px; border-radius: 10px;
}
.cluster-list a:hover { background: rgba(193, 97, 74, .1); }
.cluster-list .ico { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--c); color: #fff; flex: none; }
.cluster-list .ico svg { width: 15px; height: 15px; }

/* ---------------------------------------------------------------- conferência */
.conf-toggle { bottom: 74px; }
.conf-toggle.on { background: var(--ink); color: var(--paper-2); border-color: var(--ink); }

.conf {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  z-index: 26; width: min(390px, calc(100% - 32px));
  padding: 14px 16px 12px;
  background: var(--paper-2);
  border: 2px solid #ddc9a4; border-radius: 18px;
  box-shadow: var(--sombra);
  animation: pop .18s ease-out;
}
.conf[hidden] { display: none; }
.conf-top { display: flex; align-items: center; gap: 8px; }
.conf-count {
  font-size: 12px; font-weight: 800; letter-spacing: .4px;
  color: var(--paper-2); background: var(--ink);
  padding: 2px 9px; border-radius: 999px;
}
.conf-cat { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .6px; }
.conf-x {
  margin-left: auto; border: 0; background: none; cursor: pointer;
  font-size: 22px; line-height: 1; color: var(--ink-soft); padding: 0 2px;
}
.conf h3 { margin: 6px 0 2px; font-size: 19px; line-height: 1.15; }
.conf-coord { margin: 0 0 10px; font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.conf-acts { display: flex; gap: 8px; }
.conf-acts button {
  flex: 1; padding: 9px 10px; border-radius: 12px; cursor: pointer;
  border: 2px solid #ddc9a4; background: #fdf6e4; color: var(--ink);
  font-size: 13.5px; font-weight: 700;
}
.conf-acts button:hover { background: #f6e8c8; }
.conf-acts button:disabled { opacity: .4; cursor: default; }
@media (max-width: 640px) {
  .conf { bottom: 16px; padding: 12px 13px 10px; }
  .conf h3 { font-size: 17px; }
}

/* pino em destaque no modo conferência */
.marker.active .pin {
  box-shadow: 0 0 0 4px rgba(255, 253, 246, .95), 0 0 0 12px rgba(193, 97, 74, .35), 0 8px 18px rgba(62, 47, 28, .45);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(255, 253, 246, .95), 0 0 0 10px rgba(193, 97, 74, .28), 0 8px 18px rgba(62, 47, 28, .45); }
  50% { box-shadow: 0 0 0 4px rgba(255, 253, 246, .95), 0 0 0 18px rgba(193, 97, 74, .12), 0 8px 18px rgba(62, 47, 28, .45); }
}
.markers.revisao .marker:not(.active) { opacity: .42; transition: opacity .25s; }
.markers.revisao .marker.active { opacity: 1; z-index: 3; }

/* camada pintada em alta resolução do centrinho */
.map-detail {
  position: absolute; pointer-events: none; user-select: none;
  transition: opacity .28s ease;
  -webkit-mask-image: radial-gradient(ellipse 78% 78% at 50% 50%, #000 64%, transparent 100%);
  mask-image: radial-gradient(ellipse 78% 78% at 50% 50%, #000 64%, transparent 100%);
}
.markers.revisao .marker:not(.active) .label { opacity: 0; }
.marker.sem-rotulo .label { opacity: 0; }
.marker.sem-rotulo:hover .label, .marker.sem-rotulo.active .label { opacity: 1; }

/* atalho para a página de serviços do bairro */
.list-toggle.serv-link { bottom: 126px; text-decoration: none; display: inline-block; }
.list-toggle.agenda-link { bottom: 176px; text-decoration: none; display: inline-block; }
.com-ficha .list-toggle.agenda-link { opacity: 0; pointer-events: none; }

/* a ficha do lugar (pop-up e página) fica em css/ficha.css */
