.ofmc-overlay {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  background: rgba(0, 0, 0, .45);
}

.ofmc-modal {
  box-sizing: border-box;
  width: calc(100% - 24px);
  max-width: 520px;
  max-height: calc(100vh - 24px);
  margin: 12px auto;
  overflow: auto;
  padding: 16px;
  border-radius: 8px;
  background: #fff;
  color: #222;
  box-shadow: 0 8px 32px rgba(0, 0, 0, .3);
}

.ofmc-modal h2 {
  margin: 0 0 16px;
}

.ofmc-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.ofmc-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.ofmc-field label {
  display: block;
}

.ofmc-wide {
  grid-column: 1 / -1;
}

.ofmc-modal input,
.ofmc-modal select,
.ofmc-modal textarea,
.ofmc-panel input,
.ofmc-panel select,
.ofmc-panel textarea {
  box-sizing: border-box;
  width: 100%;
  min-height: 44px;
  padding: 8px;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #fff;
  color: #222;
  font-family: inherit;
  font-size: 16px;
}

.ofmc-field textarea {
  min-height: 88px;
  resize: vertical;
}

.ofmc-modal button,
.ofmc-panel button,
.ofmc-position button {
  box-sizing: border-box;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid #bbb;
  border-radius: 4px;
  background: #f5f5f5;
  color: #222;
  font-family: inherit;
  font-size: 16px;
  cursor: pointer;
}

.ofmc-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.ofmc-message {
  margin-top: 12px;
  color: #c62828;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.ofmc-message.ok {
  color: #2e7d32;
}

.ofmc-position {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 3100;
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 12px;
  transform: translateX(-50%);
  border-radius: 8px;
  background: #fff;
  color: #222;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

.ofmc-position p {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.ofmc-position button {
  margin: 4px;
}

.ofmc-panel {
  position: fixed;
  top: 50px;
  right: 0;
  z-index: 2500;
  box-sizing: border-box;
  width: 340px;
  max-width: 100%;
  max-height: calc(100vh - 60px);
  overflow: auto;
  padding: 14px;
  border-radius: 8px 0 0 8px;
  background: #fff;
  color: #222;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .35);
}

.ofmc-panel input,
.ofmc-panel select,
.ofmc-panel textarea {
  margin-bottom: 8px;
}

.ofmc-result,
.ofmc-panel button.ofmc-result {
  display: block;
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 10px;
  border: 0;
  border-bottom: 1px solid #ddd;
  border-radius: 0;
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.ofmc-result:hover,
.ofmc-panel button.ofmc-result:hover {
  background: #f0f0f0;
}

.ofmc-result span {
  display: block;
  overflow-wrap: anywhere;
}

.ofmc-result:focus-visible,
.ofmc-modal button:focus-visible,
.ofmc-panel button:focus-visible,
.ofmc-position button:focus-visible,
.ofmc-modal input:focus-visible,
.ofmc-modal select:focus-visible,
.ofmc-modal textarea:focus-visible,
.ofmc-panel input:focus-visible,
.ofmc-panel select:focus-visible,
.ofmc-panel textarea:focus-visible {
  outline: 2px solid #1565c0;
  outline-offset: -2px;
}

body.dark-mode .ofmc-modal,
body.dark-mode .ofmc-panel,
body.dark-mode .ofmc-position {
  background: #1f2937;
  color: #f3f4f6;
  color-scheme: dark;
}

body.dark-mode .ofmc-modal input,
body.dark-mode .ofmc-modal select,
body.dark-mode .ofmc-modal textarea,
body.dark-mode .ofmc-panel input,
body.dark-mode .ofmc-panel select,
body.dark-mode .ofmc-panel textarea {
  border-color: #4b5563;
  background: #111827;
  color: #f3f4f6;
}

body.dark-mode .ofmc-modal button,
body.dark-mode .ofmc-panel button,
body.dark-mode .ofmc-position button,
body.dark-mode .ofmc-result {
  border-color: #4b5563;
  background: #1f2937;
  color: #f3f4f6;
}

body.dark-mode .ofmc-result:hover,
body.dark-mode .ofmc-panel button.ofmc-result:hover {
  background: #374151;
}

@media (max-width: 599.98px) {
  .ofmc-fields {
    grid-template-columns: minmax(0, 1fr);
  }

  .ofmc-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ofmc-actions > * {
    box-sizing: border-box;
    width: 100%;
  }

  .ofmc-panel {
    width: 100%;
    border-radius: 0;
  }
}

/* Modo "Escolher no mapa": só o mapa e o marcador do ponto recebem cliques */
.ofmc-escolhendo .leaflet-interactive:not(.ofmc-ponto-escolhido) {
  pointer-events: none !important;
}
