:root {
  --primary: #00695c;
  --accent: #ff5722;
  --bg-light: #f0f5f4;
  --text-dark: #212121;
  --card-bg: #fff;
  --border-color: #e0e0e0;
  --shadow-color: rgba(0, 105, 92, 0.1);
  --secondary-text: #666;
  --tertiary-text: #888;
  --muted-text: #444;
  --border-light: #eee;
  --footer-bg: #fff;
  --footer-text: #666;
  --gradient-start: #004d40;
  --gradient-mid: #00796b;
  --hover-primary: #004d40;
  --active-primary: #00251a;
  --section-bg: rgba(255, 255, 255, 0.64);
  --nav-bg: rgba(255, 255, 255, 0.98);
  --danger: #d93025;
  --danger-bg: rgba(217, 48, 37, 0.1);
  --success: #16833b;
  --success-bg: rgba(22, 131, 59, 0.12);
  --warning: #9a6700;
  --warning-bg: rgba(154, 103, 0, 0.12);
  --info: #1769aa;
  --info-bg: rgba(23, 105, 170, 0.12);
}

[data-theme="dark"] {
  --primary: #26a69a;
  --accent: #ff7043;
  --bg-light: #121212;
  --text-dark: #e0e0e0;
  --card-bg: #1e1e1e;
  --border-color: #333;
  --shadow-color: rgba(0, 0, 0, 0.4);
  --secondary-text: #b0b0b0;
  --tertiary-text: #a0a0a0;
  --muted-text: #c0c0c0;
  --border-light: #333;
  --footer-bg: #1e1e1e;
  --footer-text: #b0b0b0;
  --gradient-start: #1a7a6e;
  --gradient-mid: #1a8b7a;
  --hover-primary: #1db584;
  --active-primary: #00695c;
  --section-bg: rgba(30, 30, 30, 0.7);
  --nav-bg: rgba(30, 30, 30, 0.98);
  --danger: #ff7b72;
  --danger-bg: rgba(255, 123, 114, 0.12);
  --success: #5bd778;
  --success-bg: rgba(91, 215, 120, 0.12);
  --warning: #d8a657;
  --warning-bg: rgba(216, 166, 87, 0.12);
  --info: #79c0ff;
  --info-bg: rgba(121, 192, 255, 0.12);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--bg-light);
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(90deg, var(--primary), var(--accent));
  border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--hover-primary);
}

body {
  min-height: 100vh;
  background: var(--bg-light);
  color: var(--text-dark);
  font-family: "Manrope", sans-serif;
  line-height: 1.6;
  transition: background 0.3s, color 0.3s;
}

h1,
h2,
h3,
h4,
h5,
h6,
button,
input,
select,
textarea,
.contact-btn,
.theme-toggle,
.tools-brand-title,
.section-title {
  font-family: "Poppins", sans-serif;
}

a {
  color: inherit;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

header,
.tools-header {
  position: sticky;
  top: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  background: linear-gradient(135deg, var(--primary), var(--gradient-start));
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.tools-header--app {
  min-height: 68px;
  flex: 0 0 auto;
}

.logo-section,
.tools-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  text-align: center;
}

.tools-logo-link,
.logo-clickable {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: #fff;
  text-decoration: none;
}

.logo {
  width: clamp(40px, 8vw, 52px);
  height: clamp(40px, 8vw, 52px);
  object-fit: contain;
}

.tools-header--app .logo {
  width: clamp(34px, 6vw, 44px);
  height: clamp(34px, 6vw, 44px);
}

.logo-section h1,
.tools-brand-title {
  margin: 0;
  color: #fff;
  font-size: clamp(1.25rem, 3.4vw, 1.8rem);
  font-weight: 700;
  line-height: 1.15;
}

.logo-section p,
.tools-brand-subtitle {
  margin: 0;
  color: #e0f2f1;
  font-size: 0.88rem;
  font-weight: 600;
}

.header-controls,
.tools-header-actions {
  position: absolute;
  right: clamp(1rem, 4vw, 2rem);
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.theme-toggle {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 0;
  transition: background 0.2s, transform 0.2s;
}

.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.25);
}

.theme-toggle:active {
  transform: translateY(1px);
}

.theme-icon {
  display: none;
  width: 20px;
  height: 20px;
}

.theme-icon.moon {
  display: block;
}

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

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

.main-content,
.tools-main {
  width: min(100%, 1200px);
  margin: 0 auto;
  padding: clamp(2rem, 4vw, 3rem) clamp(1rem, 4vw, 2rem);
}

.section-title {
  color: var(--primary);
  font-size: clamp(1.8rem, 5vw, 2.6rem);
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  margin-bottom: clamp(2rem, 4vw, 3rem);
  position: relative;
}

.section-title::after {
  content: "";
  display: block;
  width: 80px;
  height: 4px;
  margin: 1rem auto 0;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
}

.tools-panel,
.heatmap-container,
.suffix-container,
.kml-container,
.control-group,
.about-section {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 2px 10px var(--shadow-color);
}

.tools-panel,
.heatmap-container,
.suffix-container,
.kml-container {
  padding: clamp(1.2rem, 3vw, 1.8rem);
  margin-bottom: clamp(1.25rem, 3vw, 2rem);
}

.tools-panel-header,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.tools-panel-title,
.panel-title,
.control-group h3,
.heatmap-container h3,
.suffix-container h3,
.kml-container h3 {
  color: var(--primary);
  font-size: clamp(1.1rem, 2.5vw, 1.45rem);
  font-weight: 700;
  line-height: 1.25;
}

.tools-muted {
  color: var(--secondary-text);
}

.tools-grid,
.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
  gap: 1.2rem;
}

.contact-section {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
  padding: 1rem 0 0;
  text-align: center;
}

.contact-btn,
.tools-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  padding: 0.72rem 1rem;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.1;
  box-shadow: 0 4px 12px rgba(0, 105, 92, 0.18);
  transition: background 0.2s, border-color 0.2s, color 0.2s, box-shadow 0.2s, transform 0.2s;
}

.contact-btn:hover,
.tools-button:hover {
  background: var(--hover-primary);
  box-shadow: 0 8px 20px rgba(0, 105, 92, 0.22);
  transform: translateY(-1px);
}

.contact-btn:disabled,
.tools-button:disabled {
  opacity: 0.52;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.contact-btn.secondary,
.tools-button.secondary {
  background: var(--card-bg);
  color: var(--text-dark);
  border-color: var(--border-color);
  box-shadow: none;
}

.contact-btn.secondary:hover,
.tools-button.secondary:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.contact-btn.delete-btn,
.tools-button.delete-btn {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: rgba(217, 48, 37, 0.25);
  box-shadow: none;
}

.contact-btn.delete-btn:hover,
.tools-button.delete-btn:hover {
  background: var(--danger);
  color: #fff;
}

.contact-btn.small,
.small-btn,
.toolbar-contact-btn {
  min-height: 34px;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  font-size: 0.78rem;
}

.tools-icon,
.button-icon,
.contact-btn svg,
.tools-button svg {
  width: 1.05rem;
  height: 1.05rem;
  flex: 0 0 auto;
}

.tools-icon-button,
.close-btn,
.modal-close,
.toast-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--secondary-text);
  font-size: 1.2rem;
  line-height: 1;
  transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.tools-icon-button:hover,
.close-btn:hover,
.modal-close:hover,
.toast-close:hover {
  background: var(--section-bg);
  color: var(--primary);
  border-color: var(--primary);
}

.input-group {
  margin-bottom: 1rem;
}

.input-group:last-child {
  margin-bottom: 0;
}

.input-group label {
  display: block;
  color: var(--secondary-text);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.input-group input,
.input-group textarea,
.input-group select,
input[type="text"],
input[type="number"],
input[type="url"],
textarea,
select {
  width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-dark);
  padding: 0.72rem 0.8rem;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

textarea {
  min-height: 130px;
  resize: vertical;
}

.input-group input:focus,
.input-group textarea:focus,
.input-group select:focus,
input:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(38, 166, 154, 0.12);
}

input[type="checkbox"],
input[type="radio"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--primary);
}

input[type="range"] {
  accent-color: var(--primary);
}

.file-upload-area,
.file-drop-zone,
.tools-drop-zone {
  display: grid;
  place-items: center;
  gap: 0.7rem;
  min-height: 190px;
  border: 2px dashed rgba(0, 105, 92, 0.3);
  border-radius: 12px;
  background: var(--section-bg);
  padding: clamp(1.25rem, 4vw, 2rem);
  text-align: center;
  transition: border-color 0.2s, background 0.2s, transform 0.2s;
}

.file-upload-area:hover,
.file-upload-area.drag-over,
.file-drop-zone:hover,
.file-drop-zone.dragover,
.tools-drop-zone:hover {
  border-color: var(--primary);
  background: rgba(0, 105, 92, 0.08);
}

.upload-icon,
.style-icon,
.tool-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.status-message,
.status-toast {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 0.85rem 1rem;
  color: var(--text-dark);
  background: var(--card-bg);
}

.status-success,
.status-toast.success {
  color: var(--success);
  background: var(--success-bg);
  border-color: rgba(22, 131, 59, 0.25);
}

.status-error,
.status-toast.error {
  color: var(--danger);
  background: var(--danger-bg);
  border-color: rgba(217, 48, 37, 0.25);
}

.status-warning,
.status-toast.warning {
  color: var(--warning);
  background: var(--warning-bg);
  border-color: rgba(154, 103, 0, 0.25);
}

.status-info,
.status-toast.info {
  color: var(--info);
  background: var(--info-bg);
  border-color: rgba(23, 105, 170, 0.25);
}

.progress-bar {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--border-color);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.2s;
}

.modal,
.layers-manager-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.55);
}

.modal-content,
.layers-manager-window {
  width: min(920px, 96vw);
  max-height: min(86vh, 840px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--card-bg);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.32);
}

.modal-header,
.modal-footer,
.layers-manager-header,
.layers-manager-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-footer,
.layers-manager-footer {
  border-top: 1px solid var(--border-color);
  border-bottom: 0;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-header h3,
.layers-manager-header h3 {
  color: var(--primary);
  font-size: 1.15rem;
  font-weight: 700;
}

.modal-body,
.layers-manager-content {
  overflow: auto;
  padding: 1rem;
}

.map-container {
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  background: var(--card-bg);
}

.leaflet-container {
  font-family: "Manrope", sans-serif;
}

footer {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--footer-bg);
  color: var(--footer-text);
  text-align: center;
  font-size: 0.9rem;
}

.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;
}

@media (max-width: 768px) {
  header,
  .tools-header {
    justify-content: flex-start;
  }

  .logo-section,
  .tools-brand {
    justify-content: flex-start;
    text-align: left;
    padding-right: 3rem;
  }

  .logo-section p,
  .tools-brand-subtitle {
    display: none;
  }

  .tools-panel-header,
  .panel-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .contact-section {
    align-items: stretch;
    flex-direction: column;
  }

  .contact-section .contact-btn {
    width: 100%;
  }
}

/* ---- Overflow (3-dot) map menu — shared by the map tools ---- */
.map-menu {
  position: relative;
}

.map-menu-toggle {
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text-dark);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.35);
}

.map-menu-toggle svg {
  width: 20px;
  height: 20px;
}

.map-menu-panel {
  position: absolute;
  top: 40px;
  left: 0;
  width: 220px;
  display: none;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: var(--card-bg);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
}

/* Pinned to the right edge: open the panel toward the left. */
.map-menu--end .map-menu-panel {
  left: auto;
  right: 0;
  width: min(280px, calc(100vw - 2rem));
}

.map-menu.open .map-menu-panel {
  display: flex;
}

.map-menu-label {
  color: var(--secondary-text);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.15rem;
}

.map-menu-option {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 7px;
  font-size: 0.85rem;
  color: var(--text-dark);
  cursor: pointer;
}

.map-menu-option:hover {
  background: var(--section-bg);
}

.map-menu-option input {
  width: auto;
  accent-color: var(--primary);
}

.map-menu-sep {
  height: 1px;
  background: var(--border-color);
  margin: 0.25rem 0;
}

.map-menu-action {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--text-dark);
  padding: 0.45rem 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: left;
}

.map-menu-action:hover {
  background: var(--section-bg);
  color: var(--primary);
}

.map-menu-action svg {
  width: 1rem;
  height: 1rem;
}
