:root {
  --bg: #0f1115;
  --panel-bg: #171a21;
  --border: #2a2e38;
  --text: #e8e9ed;
  --muted: #9aa0ab;
  --empty: #4b4f58;
  --partial: #c98a2c;
  --full: #2fa85a;
  --accent: #4f8ef7;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  flex-wrap: wrap;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 160px;
}

.topbar-title h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
}

.back-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.search-wrap {
  position: relative;
  flex: 1;
  max-width: 420px;
}

#search-input {
  width: 100%;
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #0d0f13;
  color: var(--text);
  font-size: 14px;
}

#search-input:focus {
  outline: none;
  border-color: var(--accent);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-height: 320px;
  overflow-y: auto;
  z-index: 20;
}

.search-result {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.search-result:hover {
  background: #22262f;
}

.search-result .sr-sub {
  color: var(--muted);
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.dot-empty { background: var(--empty); }
.dot-partial { background: var(--partial); }
.dot-full { background: var(--full); }

.map-container {
  position: relative;
  width: 100%;
  height: calc(100vh - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#map-svg {
  width: 90%;
  height: 90%;
  transition: opacity 0.15s ease;
}

#map-svg.fading {
  opacity: 0;
}

.map-loading {
  position: absolute;
  color: var(--muted);
  font-size: 14px;
}

path.region {
  stroke: #0f1115;
  stroke-width: 0.6;
  cursor: pointer;
  transition: fill 0.15s ease, opacity 0.15s ease;
}

path.region.status-empty { fill: var(--empty); }
path.region.status-partial { fill: var(--partial); }
path.region.status-full { fill: var(--full); }

path.region:hover {
  fill: var(--accent);
}

path.region.dimmed {
  opacity: 0.15;
}

path.region.highlighted {
  stroke: #fff;
  stroke-width: 1.6;
}

.city-panel {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.city-panel[hidden] {
  display: none;
}

.city-panel-inner {
  position: relative;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-width: 760px;
  width: 92%;
  max-height: 86vh;
  overflow-y: auto;
  padding: 28px;
}

.close-btn {
  position: absolute;
  top: 10px;
  right: 14px;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 26px;
  cursor: pointer;
  line-height: 1;
}

.close-btn:hover {
  color: var(--text);
}

.city-title {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 4px;
}

.city-title h2 {
  margin: 0;
  font-size: 22px;
}

.city-uf {
  color: var(--muted);
  font-size: 14px;
}

.status-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  margin-bottom: 14px;
}

.status-badge.fetched { background: rgba(47, 168, 90, 0.2); color: var(--full); }
.status-badge.pending { background: rgba(75, 79, 88, 0.4); color: var(--muted); }
.status-badge.error { background: rgba(201, 138, 44, 0.2); color: var(--partial); }

.city-main-image {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  margin-bottom: 14px;
  display: block;
}

.city-map-svg {
  max-width: 220px;
  max-height: 220px;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  margin-bottom: 14px;
}

.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  background: #1f6feb;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}

.download-btn:hover {
  background: #2f7ffb;
}

.download-btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.download-size {
  font-weight: 400;
  opacity: 0.85;
}

.city-main-figure {
  margin: 0 0 14px;
}

/* Mapa interativo do OpenStreetMap */
.city-osm {
  margin-bottom: 14px;
}

.city-osm-frame {
  width: 100%;
  height: 200px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: block;
}

.city-osm-link {
  display: inline-block;
  font-size: 12px;
  margin-top: 6px;
  color: var(--muted);
}

.city-caption {
  font-size: 13px;
  color: var(--muted);
  font-style: italic;
  margin-top: 4px;
}

/* Galeria de fotos extras (fotomontagem), cada uma com legenda */
.city-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.city-photo-item {
  margin: 0;
}

.city-photo {
  width: 100%;
  height: 80px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  cursor: pointer;
}

.city-photo-caption {
  font-size: 11px;
  line-height: 1.3;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

/* Bandeira, brasão e mapa lado a lado, com legenda */
.city-symbols {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 14px;
}

.city-symbol {
  margin: 0;
  text-align: center;
}

.city-symbol img {
  height: 90px;
  max-width: 130px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 6px;
  display: block;
}

.city-symbol figcaption {
  font-size: 12px;
  color: var(--muted);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.city-section {
  margin-bottom: 18px;
}

.city-section h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  margin: 0 0 8px;
}

.city-summary {
  font-size: 15px;
  line-height: 1.5;
}

.city-fulltext {
  font-size: 13px;
  line-height: 1.6;
  color: #cfd2d8;
  max-height: 260px;
  overflow-y: auto;
  white-space: pre-wrap;
  background: #0d0f13;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
}

.infobox-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.infobox-table td {
  padding: 5px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.infobox-table td:first-child {
  color: var(--muted);
  width: 40%;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  background: #22262f;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  color: #cfd2d8;
}

.link-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 140px;
  overflow-y: auto;
}

.coords {
  font-size: 13px;
  color: var(--muted);
}
