:root {
  --accent: #0f7ea6;
  --accent-dark: #0a6283;
  --accent-soft: #e1f3f9;
  --bar: #242c39;
  --bg: #ffffff;
  --text: #1f2330;
  --muted: #5a6072;
  --line: #e3e5ec;
  --warn-bg: #fff6df;
  --warn-text: #7a5300;
  --topbar-h: 56px;
  --sidebar-w: 340px;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
@supports (height: 100dvh) { html, body { height: 100dvh; } }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  font-size: 15px;
  line-height: 1.45;
}
[hidden] { display: none !important; }
code { background: #f1f2f6; padding: 1px 5px; border-radius: 4px; font-size: .9em; }

:focus-visible { outline: 3px solid #f5b400; outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -50px; background: #fff; color: var(--text);
  padding: 8px 12px; border-radius: 6px; z-index: 3000;
}
.skip:focus { top: 8px; }

/* Barra superior */
.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  background: var(--bar);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  gap: 12px;
  z-index: 1200;
}
.topbar__brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar__brand > div { min-width: 0; }
.topbar__logo {
  display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px;
  background: var(--accent); color: #fff; flex: none;
}
.topbar h1 { font-size: 16px; margin: 0; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar p { margin: 0; font-size: 12px; color: #c4c8d6; }
.topbar__actions { display: flex; gap: 8px; flex: none; }

/* Botões */
.btn {
  font: inherit; font-weight: 600; font-size: 14px;
  border-radius: 8px; border: 1px solid transparent;
  padding: 8px 14px; cursor: pointer; min-height: 38px;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-dark); }
.btn--primary[aria-pressed="true"] { background: #fff; color: var(--accent-dark); border-color: var(--accent); }
.btn--ghost { background: transparent; color: #fff; border-color: #566074; }
.btn--ghost:hover { background: #323c4d; }
.btn--small { font-size: 13px; padding: 5px 10px; min-height: 32px; }
.btn--block { width: 100%; margin-top: 8px; }
.panel .btn--ghost, .local-box .btn--ghost { color: var(--text); border-color: #b9bdca; }
.panel .btn--ghost:hover { background: #f1f2f6; }
.icon-btn {
  border: 0; background: transparent; font-size: 26px; line-height: 1; cursor: pointer;
  width: 36px; height: 36px; border-radius: 8px; color: inherit;
}
.icon-btn:hover { background: rgba(0,0,0,.08); }

/* Layout */
.layout { flex: 1 1 auto; min-height: 0; display: flex; position: relative; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: #fff;
  border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0;
  z-index: 1100;
}
.sidebar__handle { display: none; }
.sidebar__content { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.sidebar__head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); }
.sidebar__count { margin: 0 0 10px; color: var(--muted); }
.sidebar__count strong { color: var(--text); font-size: 22px; }
.search input {
  width: 100%; font: inherit; padding: 9px 12px; border: 1px solid #b9bdca; border-radius: 8px;
}
.legend { display: flex; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.dot--ativo { background: var(--accent); }
.dot--instalacao { background: #fff; border: 2px dashed var(--accent); }

.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.list li { border-bottom: 1px solid var(--line); }
.item {
  display: flex; gap: 12px; align-items: flex-start; width: 100%; text-align: left;
  background: none; border: 0; font: inherit; color: inherit; padding: 12px 16px; cursor: pointer;
}
.item:hover { background: #f6f4fd; }
.item[aria-current="true"] { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }
.item__icon { flex: none; width: 28px; height: 34px; }
.item__nome { display: block; font-weight: 600; }
.item__end { display: block; font-size: 13px; color: var(--muted); }
.badge {
  display: inline-block; margin-top: 4px; font-size: 11.5px; font-weight: 600;
  padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent-dark);
}
.badge--instalacao { background: #fff; border: 1px dashed var(--accent); }
.badge--local { background: #e7f4ec; color: #1d6b3a; margin-left: 4px; }
.empty { padding: 24px 16px; color: var(--muted); text-align: center; }

/* Mapa */
.map-wrap { flex: 1; position: relative; min-width: 0; }
#mapa { position: absolute; inset: 0; background: #e8eaf0; }
#mapa.is-picking, #mapa.is-picking .leaflet-interactive { cursor: crosshair; }
.mode-banner {
  position: absolute; top: 12px; left: 64px; z-index: 900;
  background: var(--accent); color: #fff; padding: 8px 16px; border-radius: 99px;
  font-weight: 600; font-size: 13.5px; box-shadow: 0 2px 10px rgba(0,0,0,.25); max-width: calc(100% - 460px);
}
.noscript, .load-error {
  position: absolute; z-index: 900; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: #fff; padding: 14px 18px; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.2); margin: 0;
}
.load-error { color: #8a1c1c; }

/* Marcador */
.totem-pin { background: none; border: 0; }
.totem-pin svg { filter: drop-shadow(0 2px 2px rgba(0,0,0,.35)); transition: transform .15s; transform-origin: 50% 100%; }
.totem-pin:hover svg, .totem-pin.is-active svg { transform: scale(1.18); }

/* Popup */
.leaflet-popup-content-wrapper { border-radius: 12px; }
.leaflet-popup-content { margin: 14px 16px; width: 250px !important; font-family: inherit; }
.pop__foto { width: 100%; height: 150px; object-fit: cover; border-radius: 8px; margin-bottom: 8px; background: var(--accent-soft); }
.pop__nome { margin: 0 0 2px; font-size: 16px; }
.pop__end { margin: 0 0 8px; color: var(--muted); font-size: 13px; }
.pop__desc { margin: 0 0 10px; font-size: 13.5px; }
.pop__aviso {
  margin: 0 0 10px; padding: 4px 8px; border-radius: 6px; font-size: 12px;
  background: var(--warn-bg); color: var(--warn-text);
}
.pop__btn {
  display: block; text-align: center; background: var(--accent); color: #fff !important;
  text-decoration: none; font-weight: 600; padding: 9px 12px; border-radius: 8px;
}
.pop__btn:hover { background: var(--accent-dark); }

/* Painel de cadastro */
.panel {
  position: absolute; top: 12px; right: 12px; width: 340px; max-height: calc(100% - 24px);
  overflow-y: auto; background: #fff; border-radius: 12px; z-index: 1000;
  box-shadow: 0 6px 24px rgba(0,0,0,.28); padding: 14px 16px 16px;
}
.panel__head { display: flex; justify-content: space-between; align-items: center; }
.panel__head h2 { margin: 0; font-size: 17px; }
.panel__note { font-size: 12.5px; color: var(--muted); margin: 6px 0 10px; }
.panel label, .output label { display: block; font-weight: 600; font-size: 13px; margin: 10px 0 4px; }
.panel input, .panel textarea, .panel select {
  width: 100%; font: inherit; padding: 8px 10px; border: 1px solid #b9bdca; border-radius: 8px; background: #fff;
}
.panel textarea { resize: vertical; }
.coords {
  margin: 0; padding: 8px 10px; background: var(--accent-soft); border-radius: 8px;
  font-size: 13px; color: var(--accent-dark); font-weight: 600;
}
.coords.is-set { background: #e7f4ec; color: #1d6b3a; }
.form-error { color: #a31616; font-size: 13px; margin: 8px 0 0; font-weight: 600; }
.output { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 4px; }
.output textarea { font-family: ui-monospace, Consolas, monospace; font-size: 12.5px; }
.output__actions { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.copied { color: #1d6b3a; font-weight: 600; font-size: 13px; }
.local-box { margin-top: 14px; padding-top: 10px; border-top: 1px solid var(--line); font-size: 13px; }
.local-box p { margin: 0 0 8px; }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 2000; background: rgba(20,22,30,.65);
  display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto;
}
.modal__box {
  position: relative; background: #fff; border-radius: 16px; max-width: 880px; width: 100%;
  padding: 28px; max-height: 100%; overflow-y: auto;
}
.modal__close { position: absolute; top: 10px; right: 10px; }
.modal__intro { display: flex; gap: 28px; align-items: center; margin-bottom: 22px; }
.modal__intro h2 { margin: 4px 0 8px; font-size: 24px; line-height: 1.2; }
.modal__intro p { margin: 0; color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: 12px; font-weight: 700; color: var(--accent) !important; }
.blocks { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.block { border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.block h3 { margin: 8px 0 4px; font-size: 16px; }
.block p { margin: 0; font-size: 14px; color: var(--muted); }
.block__n {
  display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent); color: #fff; font-weight: 700; font-size: 13px;
}

/* Ilustração do totem em CSS */
.modal__art { flex: none; width: 150px; }
.art-totem { width: 120px; margin: 0 auto; }
.art-totem__screen {
  background: #fff; border: 7px solid #15161c; border-bottom-width: 7px; border-radius: 6px 6px 0 0;
  height: 150px; padding: 10px 8px; display: flex; flex-direction: column; gap: 7px; align-items: center;
  position: relative; box-shadow: 0 0 0 1px #3a3d4a;
}
.art-totem__tag {
  background: var(--accent); color: #fff; font-size: 10px; font-weight: 700; text-align: center;
  padding: 5px 4px; border-radius: 4px; line-height: 1.15; width: 100%;
}
.art-totem__line { height: 6px; width: 100%; background: #d9dbe5; border-radius: 3px; }
.art-totem__line--short { width: 60%; align-self: flex-start; }
.art-totem__qr {
  margin-top: auto; width: 34px; height: 34px;
  background:
    conic-gradient(#15161c 25%, #fff 0 50%, #15161c 0 75%, #fff 0) 0 0 / 11px 11px;
  border: 3px solid #fff; outline: 1px solid #15161c;
}
.art-totem__body { background: #15161c; height: 80px; margin: 0; border-radius: 0 0 2px 2px; box-shadow: 0 0 0 1px #3a3d4a; }
.art-totem__base { background: #aeb3c2; height: 8px; margin: 0 -14px; border-radius: 3px; }

/* Responsivo */
@media (max-width: 760px) {
  .topbar { padding: 0 10px; }
  .topbar__brand p { display: none; }
  .btn { padding: 8px 10px; font-size: 13px; }
  .layout { display: block; }
  .map-wrap { position: absolute; inset: 0; }
  .sidebar {
    position: absolute; left: 0; right: 0; bottom: 0; width: auto; height: 62px;
    border-right: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -4px 18px rgba(0,0,0,.22);
    transition: height .25s ease; overflow: hidden;
  }
  .sidebar.is-open { height: 72%; }
  .sidebar__count { display: none; }
  .sidebar__head { padding: 8px 12px 8px; }
  .sidebar .chips { flex-wrap: nowrap; overflow-x: auto; margin-top: 8px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .sidebar .chip { flex: none; white-space: nowrap; }
  .legend { margin-top: 6px; }
  .sidebar__handle {
    display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%;
    background: none; border: 0; font: inherit; font-weight: 700; padding: 8px 0 10px; min-height: 62px; cursor: pointer; color: var(--text);
  }
  .sidebar__handle-bar { width: 40px; height: 5px; border-radius: 3px; background: #b9bdca; }
  .sidebar__content { overflow: hidden; visibility: hidden; }
  .sidebar.is-open .sidebar__content { visibility: visible; }
  .panel {
    top: auto; bottom: 0; left: 0; right: 0; width: auto; max-height: 50%;
    border-radius: 16px 16px 0 0; z-index: 1300;
  }
  .mode-banner { top: 8px; left: 56px; right: 8px; max-width: none; border-radius: 12px; font-size: 12.5px; }
  .modal__intro { flex-direction: column; text-align: center; gap: 14px; }
  .modal__intro h2 { font-size: 20px; }
  .blocks { grid-template-columns: 1fr; }
  .modal__box { padding: 20px 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 480px) { .topbar__logo { display: none; } .topbar h1 { font-size: 15px; white-space: normal; line-height: 1.2; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; } }

/* filtros por categoria */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  font: inherit; font-size: 13px; padding: 5px 11px; min-height: 32px; border-radius: 99px; cursor: pointer;
  background: #fff; color: var(--text); border: 1px solid #b9bdca;
}
.chip:hover { background: var(--accent-soft); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.badge--cat { background: #eef0f4; color: var(--muted); margin-right: 6px; }

.modal__art { width: 130px; }
.art-img { display: block; width: 100%; height: auto; filter: drop-shadow(0 8px 10px rgba(0,0,0,.25)); }

/* foto ampliável */
.pop__zoom { position: relative; display: block; width: 100%; padding: 0; margin: 0 0 8px; border: 0; background: none; cursor: zoom-in; border-radius: 8px; overflow: hidden; }
.pop__zoom .pop__foto { display: block; margin: 0; transition: transform .2s ease; }
.pop__zoom:hover .pop__foto { transform: scale(1.03); }
.pop__zoom:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pop__zoom-tag {
  position: absolute; right: 8px; bottom: 8px; background: rgba(20,26,36,.82); color: #fff;
  font-size: 12px; font-weight: 600; padding: 4px 9px; border-radius: 99px; pointer-events: none;
}
.lightbox { position: fixed; inset: 0; z-index: 2000; background: rgba(10,14,20,.92); display: flex; align-items: center; justify-content: center; padding: 16px; }
.lightbox__fig { margin: 0; max-width: 100%; max-height: 100%; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.lightbox__fig img { max-width: 100%; max-height: calc(100dvh - 90px); border-radius: 8px; background: #fff; object-fit: contain; }
.lightbox figcaption { color: #fff; font-weight: 600; text-align: center; }
.lightbox__close { position: absolute; top: 12px; right: 12px; font-size: 28px; color: #fff; background: rgba(255,255,255,.14); border-radius: 99px; width: 44px; height: 44px; }
.lightbox__close:hover { background: rgba(255,255,255,.26); }

/* estados de carregamento e erro */
.skel { display: grid; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.skel span { display: block; height: 12px; border-radius: 6px; background: linear-gradient(90deg, #eceef3 25%, #f6f7fa 50%, #eceef3 75%); background-size: 200% 100%; animation: skel 1.2s linear infinite; }
.skel span:first-child { width: 62%; height: 14px; }
.skel span:last-child { width: 85%; }
@keyframes skel { from { background-position: 200% 0; } to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel span { animation: none; } }
.load-error { text-align: center; color: var(--text); max-width: calc(100% - 32px); }
.load-error p { margin: 0 0 10px; color: #8a1c1c; font-weight: 600; }
.tiles-aviso {
  position: absolute; z-index: 900; top: 12px; left: 56px; right: 12px; margin: 0 auto; max-width: 440px;
  background: var(--warn-bg); color: var(--warn-text); padding: 8px 14px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 2px 10px rgba(0,0,0,.18); text-align: center;
}
.btn:active, .chip:active, .pop__btn:active { transform: scale(.98); }

/* Modo em breve: rede em implantação (status "previsto" no totens.json) */
.dot--previsto { background: #fff; border: 2px dotted #7b8aa3; }
.badge--previsto { background: #f1f3f7; color: #4d5a70; border: 1px dotted #7b8aa3; }
.pop__aviso--previsto { background: #f1f3f7; color: #4d5a70; }
.aviso-rede {
  position: absolute; z-index: 850; top: 12px; left: 56px; right: 12px; margin: 0 auto; max-width: 480px;
  background: rgba(255,255,255,.94); color: #3b4558; padding: 6px 12px; border-radius: 99px;
  font-size: 12.5px; font-weight: 500; line-height: 1.35; text-align: center; box-shadow: 0 1px 6px rgba(0,0,0,.15);
}
.aviso-rede:not([hidden]) ~ .tiles-aviso { top: 52px; }
@media (max-width: 760px) {
  .aviso-rede { top: 8px; left: 52px; right: 8px; border-radius: 12px; font-size: 12px; }
}

/* popup: "Quero anunciar neste ponto" é o botão principal; "Como chegar" vira link secundário */
.pop__btn + .pop__link, .pop__link { display: block; margin-top: 8px; text-align: center; color: var(--accent-dark) !important; font-size: 13px; font-weight: 600; }
/* modal "Como anunciar": CTA no fim */
.modal__cta { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 20px; margin-top: 20px; }
.modal__cta .btn { display: inline-flex; align-items: center; text-decoration: none; padding: 11px 20px; }
.modal__link { color: var(--accent-dark); font-weight: 600; font-size: 14px; }
