:root {
  color-scheme: light;
  --header-height: 68px;
  --surface: rgba(255, 255, 255, 0.96);
  --surface-solid: #ffffff;
  --surface-soft: #f3f5f8;
  --text: #172033;
  --muted: #647084;
  --border: rgba(23, 32, 51, 0.14);
  --shadow: 0 14px 38px rgba(15, 23, 42, 0.16);
  --accent: #1d4ed8;
  --accent-soft: #e8efff;
  --online: #138a47;
  --warning: #c27803;
  --offline: #c43232;
  --focus: #2563eb;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: rgba(17, 24, 39, 0.96);
  --surface-solid: #111827;
  --surface-soft: #202938;
  --text: #f3f6fb;
  --muted: #a9b4c5;
  --border: rgba(255, 255, 255, 0.14);
  --shadow: 0 14px 38px rgba(0, 0, 0, 0.4);
  --accent: #7aa2ff;
  --accent-soft: #24375e;
  --online: #4ed484;
  --warning: #f4b84b;
  --offline: #ff7777;
  --focus: #8bb1ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--surface-solid);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 42%, transparent);
  outline-offset: 2px;
}

.app-shell {
  height: 100%;
}

.topbar {
  position: relative;
  z-index: 100;
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-solid);
}

.brand {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 0;
  color: inherit;
  text-decoration: none;
}


.brand-copy {
  min-width: 0;
  display: grid;
  line-height: 1.15;
}

.brand-copy strong {
  font-size: 1rem;
  font-weight: 700;
}

.brand-copy span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.78rem;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.icon-button,
.panel-close,
.search-box button,
.message-banner button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.icon-button {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-soft);
}

.icon-button:hover {
  background: var(--accent-soft);
}

.icon-button svg,
.panel-close svg,
.search-box svg,
.message-banner svg,
.panel-toggle svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.theme-icon-dark {
  display: none;
}

:root[data-theme="dark"] .theme-icon-light {
  display: none;
}

:root[data-theme="dark"] .theme-icon-dark {
  display: block;
}

.map-stage {
  position: relative;
  height: calc(100% - var(--header-height));
  overflow: hidden;
}

#map {
  position: absolute;
  inset: 0;
}

.summary-strip {
  position: absolute;
  z-index: 20;
  top: 14px;
  right: 14px;
  max-width: calc(100% - 420px);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.summary-item {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 9px;
  border-radius: 9px;
}

.summary-item strong {
  min-width: 24px;
  text-align: right;
  font-size: 0.95rem;
}

.summary-label,
.summary-updated {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.summary-updated {
  padding: 0 8px;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 auto;
  border-radius: 999px;
}

.summary-online .status-dot {
  background: var(--online);
}

.summary-warning .status-dot {
  background: var(--warning);
}

.summary-offline .status-dot {
  background: var(--offline);
}

.repeater-panel {
  position: absolute;
  z-index: 30;
  top: 14px;
  bottom: 14px;
  left: 14px;
  width: min(372px, calc(100% - 28px));
  display: flex;
  flex-direction: column;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  transition: transform 180ms ease, opacity 180ms ease;
}

.repeater-panel.is-hidden {
  transform: translateX(calc(-100% - 28px));
  opacity: 0;
  pointer-events: none;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h1 {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.25;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.panel-close {
  width: 34px;
  height: 34px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 9px;
}

.panel-close:hover {
  background: var(--surface-soft);
}

.search-box {
  position: relative;
  margin-top: 15px;
  display: flex;
  align-items: center;
}

.search-box > svg {
  position: absolute;
  left: 12px;
  z-index: 1;
  color: var(--muted);
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 44px;
  padding: 0 42px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--muted);
}

.search-box button {
  position: absolute;
  right: 5px;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 9px;
}

.filters {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-solid);
  cursor: pointer;
  color: var(--muted);
  font-size: 0.78rem;
}

.filter-button:hover {
  color: var(--text);
  border-color: var(--accent);
}

.filter-button.is-active {
  border-color: transparent;
  background: var(--accent);
  color: #ffffff;
}

:root[data-theme="dark"] .filter-button.is-active {
  color: #0b1220;
}

.repeater-list {
  min-height: 0;
  margin-top: 12px;
  padding-right: 3px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.repeater-card {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 11px;
  padding: 11px 8px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.repeater-card:hover {
  border-radius: 10px;
  background: var(--surface-soft);
}

.repeater-card img {
  width: 28px;
  height: 28px;
}

.repeater-card-copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.repeater-card-title {
  overflow: hidden;
  color: var(--text);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repeater-card-description,
.repeater-card-meta {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.77rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.repeater-card-days {
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.empty-state {
  padding: 30px 14px;
  color: var(--muted);
  text-align: center;
  font-size: 0.9rem;
}

.panel-toggle {
  position: absolute;
  z-index: 25;
  top: 14px;
  left: 14px;
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.panel-toggle.is-visible {
  opacity: 1;
  pointer-events: auto;
}


.loading-overlay {
  position: absolute;
  z-index: 60;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  background: color-mix(in srgb, var(--surface-solid) 72%, transparent);
  color: var(--text);
  transition: opacity 180ms ease;
}

.loading-overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 999px;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.message-banner {
  position: absolute;
  z-index: 70;
  left: 50%;
  bottom: 22px;
  max-width: min(560px, calc(100% - 28px));
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px 11px 15px;
  border: 1px solid color-mix(in srgb, var(--offline) 45%, var(--border));
  border-radius: 12px;
  background: var(--surface-solid);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
}

.message-banner[data-type="success"] {
  border-color: color-mix(in srgb, var(--online) 55%, var(--border));
}

.message-banner span {
  font-size: 0.86rem;
}

.message-banner button {
  width: 30px;
  height: 30px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
}

.message-banner button:hover {
  background: var(--surface-soft);
}

.info-window {
  min-width: min(300px, 70vw);
  max-width: 360px;
  color: #182133;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.info-window-header {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.info-window-header img {
  width: 30px;
  height: 30px;
}

.info-window-title {
  font-size: 1rem;
  font-weight: 800;
}

.info-window-subtitle {
  margin-top: 2px;
  color: #657086;
  font-size: 0.78rem;
}

.info-window-description {
  margin: 8px 0 10px;
  color: #3c465b;
  font-size: 0.83rem;
  line-height: 1.4;
}

.info-window-grid {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 5px 10px;
  font-size: 0.8rem;
}

.info-window-grid dt {
  color: #657086;
  font-weight: 600;
}

.info-window-grid dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.info-window-link {
  display: inline-flex;
  margin-top: 12px;
  color: #1d4ed8;
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
}

.info-window-link:hover {
  text-decoration: underline;
}

.icon-button.is-spinning svg {
  animation: spin 750ms linear infinite;
}

@media (max-width: 900px) {
  .summary-strip {
    max-width: calc(100% - 28px);
  }

  .summary-label {
    display: none;
  }

  .summary-updated {
    display: none;
  }
}

@media (max-width: 680px) {
  :root {
    --header-height: 60px;
  }

  .topbar {
    padding: 6px 10px;
  }

  .brand {
    gap: 8px;
  }

  .brand img {
    width: 91px;
    height: 34px;
  }

  .brand-copy strong {
    font-size: 0.88rem;
  }

  .brand-copy span {
    display: none;
  }

  .icon-button {
    width: 38px;
    height: 38px;
    border-radius: 10px;
  }

  .repeater-panel {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: min(66vh, 590px);
    border-radius: 17px;
  }

  .repeater-panel.is-hidden {
    transform: translateY(calc(100% + 24px));
  }

  .panel-toggle {
    top: auto;
    bottom: 14px;
    left: 14px;
  }

  .summary-strip {
    top: 10px;
    right: 10px;
    max-width: calc(100% - 20px);
    gap: 2px;
  }

  .summary-item {
    min-height: 30px;
    padding: 4px 7px;
  }

  .message-banner {
    bottom: 72px;
  }
}

@media (max-width: 420px) {
  .brand-copy {
    display: none;
  }

  .topbar-actions {
    gap: 5px;
  }

  .summary-strip {
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Integração Leaflet */
.topbar {
  z-index: 2000;
}

.summary-strip {
  z-index: 1200;
}

.panel-toggle {
  z-index: 1250;
}

.repeater-panel {
  z-index: 1300;
}


.loading-overlay {
  z-index: 1600;
}

.message-banner {
  z-index: 1700;
}

.leaflet-container {
  width: 100%;
  height: 100%;
  background: #dfe5eb;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.leaflet-control-zoom {
  margin-top: 14px !important;
  margin-right: 14px !important;
  border: 1px solid var(--border) !important;
  border-radius: 12px !important;
  box-shadow: var(--shadow) !important;
  overflow: hidden;
}

.leaflet-control-zoom a {
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  border: 0 !important;
  border-bottom: 1px solid var(--border) !important;
  background: var(--surface) !important;
  color: var(--text) !important;
}

.leaflet-control-zoom a:last-child {
  border-bottom: 0 !important;
}

.leaflet-control-zoom a:hover {
  background: var(--surface-soft) !important;
}

.leaflet-control-attribution {
  margin: 0 !important;
  padding: 3px 7px !important;
  background: var(--surface) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
  backdrop-filter: blur(8px);
}

.leaflet-control-attribution a {
  color: var(--accent) !important;
}

.leaflet-popup-content-wrapper,
.leaflet-popup-tip {
  background: var(--surface-solid);
  color: var(--text);
}

.leaflet-popup-content-wrapper {
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.leaflet-popup-content {
  margin: 14px 16px 15px;
}

.leaflet-popup-close-button {
  top: 5px !important;
  right: 6px !important;
  color: var(--muted) !important;
  font-size: 22px !important;
}

.info-window {
  min-width: min(280px, 68vw);
  color: var(--text);
}

.info-window-subtitle,
.info-window-grid dt {
  color: var(--muted);
}

.info-window-description {
  color: color-mix(in srgb, var(--text) 82%, var(--muted));
}

.info-window-link {
  color: var(--accent);
}

.dmr-marker {
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3));
}


.repeater-cluster-wrapper {
  border: 0;
  background: transparent;
}

.repeater-cluster {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 3px solid var(--surface-solid);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 800;
}

:root[data-theme="dark"] .repeater-cluster {
  color: #0b1220;
}

:root[data-theme="dark"] .leaflet-tile-pane {
  filter: brightness(0.72) contrast(1.08) saturate(0.72);
}

@media (max-width: 680px) {
  .leaflet-control-zoom {
    margin-top: 64px !important;
    margin-right: 10px !important;
  }

  .leaflet-control-attribution {
    max-width: 62vw;
    white-space: normal;
    line-height: 1.2;
  }
}
