:root {
  --brand-primary: #0d9488;
  --brand-dark: #0f172a;
  --brand-light: #e0f2f1;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --bg-panel: #ffffff;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", Tahoma, sans-serif;
  background: #f3f4f6;
  color: #0f172a;
}

body.dark {
  background: #020617;
  color: #f8fafc;
}

.map-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.map-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: linear-gradient(90deg, #666868, #233138);
  color: #fff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.map-brand-link {
  text-decoration: none;
  color: inherit;
}

.map-brand {
  display: flex;
  align-items: center;
  gap: 16px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.map-brand img {
  height: 42px;
}

.map-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.map-body {
  flex: 1;
  display: flex;
  min-height: 0;
}

.map-sidebar {
  width: 340px;
  background: var(--bg-panel);
  padding: 24px;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

body.dark .map-sidebar {
  background: #0f172a;
  border-right-color: #1e293b;
}

.map-sidebar h2 {
  margin: 0;
  font-size: 1.1rem;
}

.map-section {
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 16px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.05);
}

body.dark .map-section {
  background: #111c30;
  border-color: #1e293b;
  box-shadow: none;
}

.map-section h3 {
  margin: 0 0 10px;
  font-size: 0.95rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.form-control {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.95rem;
  background: #fff;
}

body.dark .form-control {
  background: #0f172a;
  color: #f8fafc;
  border-color: #1e293b;
}

.btn {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 10px;
  border: none;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--brand-primary);
  color: #fff;
}

.btn-secondary {
  background: #e2e8f0;
  color: #0f172a;
}

body.dark .btn-secondary {
  background: #1f2937;
  color: #e2e8f0;
}

.btn-outline {
  background: transparent;
  color: inherit;
  border: 1px solid var(--border-color);
}

.chip-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 180px;
  overflow-y: auto;
}

.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  font-size: 0.9rem;
}

.chip input {
  accent-color: var(--brand-primary);
}

.chip-color {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.map-area {
  flex: 1;
  position: relative;
  min-height: 0;
}

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

.map-legend {
  position: absolute;
  bottom: 18px;
  right: 18px;
  background: rgba(255, 255, 255, 0.9);
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
  font-size: 0.85rem;
}

body.dark .map-legend {
  background: rgba(15, 23, 42, 0.85);
  color: #f8fafc;
}

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

.legend-item:last-child {
  margin-bottom: 0;
}

.legend-color {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.search-results {
  margin-top: 10px;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fff;
}

body.dark .search-results {
  background: #0f172a;
  border-color: #1e293b;
}

.search-result-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background: #f8fafc;
}

body.dark .search-result-item:hover {
  background: #1e293b;
}

.no-results {
  padding: 10px 12px;
  color: var(--text-muted);
}

.switch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.9rem;
}

.switch input {
  width: 42px;
  height: 24px;
  appearance: none;
  background: #cbd5f5;
  border-radius: 999px;
  position: relative;
  cursor: pointer;
}

.switch input:checked {
  background: var(--brand-primary);
}

.switch input::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.2s ease;
}

.switch input:checked::after {
  transform: translateX(18px);
}

.inline-buttons {
    display: flex;
    gap: 8px;
}
.small-buttons .btn {
  flex: 1;
  font-size: 0.82rem;
  padding: 7px 10px;
}

.map-footer {
  position: absolute;
  right: 18px;
  top: 18px;
  display: flex;
  gap: 10px;
}

.status-bar {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--brand-light);
  font-size: 0.75rem;
  color: #0f172a;
}

body.dark .tag {
  background: rgba(14, 165, 233, 0.15);
  color: #bae6fd;
}

/* Estilo consistente dos info windows (mapas) com dark mode */
.info-window {
  max-width: 260px;
  font-family: inherit;
  background: #fff;
  color: #0f172a;
  padding: 12px;
  border-radius: 12px;
  box-shadow: 0 12px 24px rgba(15, 23, 42, 0.25);
}
body.dark .info-window {
  background: #0f172a;
  color: #e2e8f0;
  box-shadow: 0 12px 24px rgba(0,0,0,0.55);
}

/* Modais modernas */
.modal-modern {
  width: min(640px, 96%);
  background: #fff;
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.35);
}
body.dark .modal-modern {
  background: #0f172a;
  color: #e2e8f0;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.65);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}
.modal-actions-inline {
  display: flex;
  gap: 8px;
}
.table-scroll {
  max-height: 260px;
  overflow: auto;
  border: 1px solid var(--border-color);
  border-radius: 10px;
}
table#preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
#preview-table th, #preview-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-color);
}
#preview-table th {
  background: #f1f5f9;
  text-align: left;
}
body.dark #preview-table th {
  background: #111c30;
}
.mass-preview.hidden { display: none; }
.color-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}
.color-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
}
body.dark .color-chip {
  border-color: #1e293b;
}
