/* ==========================================================================
OFFSETMAP :: Awwwards-Grade Dark UI v7.0 (Modified v1 w/ selected v2 effects)
========================================================================== */

/* ==========================================================================

1. Fonts, Variables, Resets
========================================================================== */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");
@import url("https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700;800&display=swap");

:root {
  --font-sans: 'Inter', system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, 'Helvetica Neue', Arial, sans-serif;
  --font-display: 'Poppins', var(--font-sans);

  /* Core Palette (Dark-first) */
  --color-bg-deep: #070b11;
  --color-bg-primary: #0b111a;
  --color-bg-gradient-1: #0b111a;
  --color-bg-gradient-2: #0f1725;
  --color-bg-gradient-3: #101a2a;

  --color-surface-glass: rgba(20, 27, 40, 0.75);
  --color-surface-glass-strong: rgba(25, 33, 48, 0.92);
  --color-surface-raised: #151e2d;
  --color-surface-inset: #0a0f18;

  --color-border-primary: rgba(255, 255, 255, 0.14);
  --color-border-secondary: rgba(255, 255, 255, 0.07);

  --color-text-primary: #eef2ff;
  --color-text-secondary: #aab3c7;
  --color-text-tertiary: #6e7a91;
  --color-text-interactive: #dfe6ff;

  /* Accents */
  --color-accent-primary: #60a5fa;
  /* Blue 400 */
  --color-accent-primary-hover: #3b82f6;
  /* Blue 500 */
  --color-accent-primary-glow: rgba(96, 165, 250, 0.45);
  --color-accent-danger: #ef4444;
  --color-accent-danger-hover: #dc2626;
  --color-accent-highlight: #facc15;
  /* amber glow for badges */

  /* Radii */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 6px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 14px 28px rgba(0, 0, 0, 0.45);
  --shadow-xl: 0 28px 48px rgba(0, 0, 0, 0.55);
  --shadow-glow-accent: 0 0 0 3px var(--color-accent-primary-glow), 0 0 24px rgba(96, 165, 250, 0.15);

  /* Subtle geomorphic highlight (added) */
  --shadow-geomorphic-inset: inset 0 1px 0 rgba(255, 255, 255, 0.03);

  /* Motion */
  --transition-fast: 140ms cubic-bezier(.2, .7, .2, 1);
  --transition-normal: 280ms cubic-bezier(.2, .7, .2, 1);
  --transition-slow: 600ms cubic-bezier(.2, .7, .2, 1);

  /* Z */
  --z-map-controls: 450;
  --z-floating-ui: 1000;
  --z-modal: 5000;
  --z-overlay: 10000;

  /* Layout */
  --filter-bar-width: 450px;
  --top-bar-height: 56px;

  accent-color: var(--color-accent-primary);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

/* Cinematic dark gradient + ultra-subtle pattern */
body {
  font-family: var(--font-sans);
  color: var(--color-text-primary);
  background:
    radial-gradient(1200px 600px at 15% 10%, rgba(59, 130, 246, 0.05), transparent 60%),
    radial-gradient(1000px 600px at 80% 15%, rgba(250, 204, 21, 0.04), transparent 65%),
    conic-gradient(from 210deg at 50% 120%, var(--color-bg-gradient-1), var(--color-bg-gradient-2), var(--color-bg-gradient-3), var(--color-bg-gradient-2)),
    linear-gradient(180deg, #070b11, #070b11);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  position: relative;
  isolation: isolate;
}

/* Filmic vignette */
body::before {
  content: "";
  position: fixed;
  inset: -10vh -10vw;
  pointer-events: none;
  background:
    radial-gradient(1200px 900px at -20% -10%, rgba(255, 255, 255, 0.04), transparent 55%),
    radial-gradient(1200px 900px at 120% -10%, rgba(255, 255, 255, 0.03), transparent 50%),
    radial-gradient(1600px 900px at 50% 120%, rgba(0, 0, 0, 0.35), transparent 60%);
  z-index: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--color-text-primary);
}

a {
  color: var(--color-accent-primary);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: #fff;
}

a:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
  border-radius: 8px;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background-color: rgba(150, 168, 205, 0.35);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background-color: rgba(150, 168, 205, 0.55);
}

/* Hide hidden H1 container */
body>span:first-of-type {
  display: none !important;
}

/* ==========================================================================
2) Core Layout & Containers
========================================================================== */
.main-container {
  position: relative;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  display: flex;
}

#content-container {
  position: relative;
  flex-grow: 1;
  height: 100%;
  transition: padding-left var(--transition-normal), transform var(--transition-normal);
}

#map,
#table-container {
  position: absolute;
  inset: 0;
  transition: right var(--transition-normal), opacity var(--transition-normal);
}

.leaflet-container {
  background: var(--color-bg-primary);
}

/* Table View */
#table-container {
  display: none;
  overflow: auto;
  padding: 72px 20px 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02)),
    var(--color-bg-primary);
  border-top: 1px solid var(--color-border-primary);
}

/* Push map/table when filter visible */
#content-container.filter-is-active #map,
#content-container.filter-is-active #table-container {
  right: var(--filter-bar-width);
}

/* ==========================================================================
3) Top Buttons & Social Icons
========================================================================== */
#button-container {
  position: absolute;
  top: 1rem;
  left: 25%;
  transform: translateX(-25%);
  display: flex;
  gap: .75rem;
  align-items: center;
  padding: .5rem;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-geomorphic-inset);
  /* subtle geomorphic */
  z-index: var(--z-floating-ui);
  transition: box-shadow var(--transition-normal), transform var(--transition-fast);
  /* FIX: Prevents container from blocking map clicks */
  pointer-events: none;
}

/* ADD THIS NEW RULE right after the one above */
#button-container>.unified-button {
  pointer-events: auto;
}

body.non-map-layout #button-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--top-bar-height);
  transform: none;
  border-radius: 0;
  justify-content: center;
  background: linear-gradient(180deg, rgba(12, 18, 30, 0.85), rgba(12, 18, 30, 0.75));
  border-bottom: 1px solid var(--color-border-primary);
}

body.non-map-layout .main-container {
  padding-top: var(--top-bar-height);
}

body.non-map-layout .social-icons,
body.non-map-layout .filter-container {
  display: none;
}

.unified-button {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: .02em;
  font-size: clamp(.8rem, .75rem + .2vw, .92rem);
  color: var(--color-text-interactive);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
  border: 1px solid var(--color-border-secondary);
  padding: .6rem 1.2rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

/* Borrowed v2 cyan glow ONLY */
.unified-button:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.05));
  color: #fff;
  border-color: #25b7f8;
  transform: translateY(-1px);
  box-shadow: 0 0 8px rgba(37, 183, 248, 0.7);
}

.unified-button:focus-visible {
  outline: none;
  box-shadow: 0 0 8px rgba(37, 183, 248, 0.7);
  border-color: #25b7f8;
}

.unified-button:active {
  transform: translateY(0);
  box-shadow: 0 0 4px rgba(37, 183, 248, 0.5);
  border-color: #25b7f8;
}

.unified-button:disabled {
  opacity: .6;
  cursor: not-allowed;
  filter: grayscale(.2);
}

.social-icons {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  z-index: var(--z-floating-ui);
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.social-icons a {
  display: block;
  line-height: 0;
}

.social-icons img {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.4)) invert(1) saturate(1.2);
  transition: filter var(--transition-fast), transform var(--transition-fast);
}

.social-icons a:hover img {
  filter: invert(1) saturate(1.5);
  transform: translateY(-1px) scale(1.05);
}

.social-icons a:focus-visible img {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
  border-radius: 8px;
}

/* ==========================================================================
4) Filter Panel (Right Sidebar)
========================================================================== */
.filter-container {
  position: absolute;
  top: 0;
  right: 0;
  width: var(--filter-bar-width);
  height: 100vh;
  z-index: var(--z-floating-ui);
  display: flex;
  transform: translateX(0);
  transition: transform var(--transition-normal);
}

.filter-container.collapsed {
  transform: translateX(100%);
}

.filter-toggle {
  position: absolute;
  left: -42px;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 64px;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--color-border-primary);
  border-right: none;
  border-radius: var(--radius-md) 0 0 var(--radius-md);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-secondary);
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-md), var(--shadow-geomorphic-inset);
  /* subtle geomorphic */
}

.filter-toggle:hover {
  background: #192338;
  color: var(--color-text-primary);
}

.filter-toggle:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

.filter-toggle i {
  font-size: 1.25rem;
  transition: transform var(--transition-normal);
}

.filter-container:not(.collapsed) .filter-toggle i {
  transform: rotate(180deg);
}

.filter {
  width: 100%;
  height: 100%;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--color-border-primary);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.35), var(--shadow-geomorphic-inset);
  /* subtle geomorphic */
}

.filter-content {
  flex-grow: 1;
  overflow-y: auto;
  position: relative;
  padding: 1rem 1rem 4.25rem;
}

#marker-count {
  background: linear-gradient(180deg, #fde047, #facc15);
  color: #1a1a1a;
  font-weight: 800;
  font-size: .92rem;
  padding: .8rem 1rem;
  border-radius: var(--radius-md);
  text-align: center;
  margin-bottom: 1rem;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 10px 30px rgba(250, 204, 21, 0.35), inset 0 -2px 0 rgba(0, 0, 0, 0.15);
}

.filter-buttons {
  display: flex;
  justify-content: space-around;
  gap: .6rem;
  margin-bottom: 1.5rem;
}

.category-button {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.03));
  border: 2px solid var(--color-border-primary);
  border-radius: 50%;
  padding: 6px;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.category-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.category-button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

.category-button.active {
  border-color: var(--color-accent-primary);
}

.category-button img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

.filter .unified-button:not(.reset-filters) {
  width: 100%;
  margin-bottom: 1rem;
}

#search-form .search-bar-wrapper {
  margin-bottom: 1rem;
}

#search-form .search-bar {
  display: flex;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  background: var(--color-surface-inset);
  overflow: hidden;
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.03);
}

#search-form input[type="text"] {
  flex-grow: 1;
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  padding: .65rem .8rem;
  font-size: .9rem;
  outline: none;
}

#search-form input[type="text"]::placeholder {
  color: var(--color-text-tertiary);
}

#search-form button {
  background: linear-gradient(180deg, #182237, #121a2b);
  border: none;
  border-left: 1px solid var(--color-border-primary);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0 .9rem;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

#search-form button:hover {
  background: var(--color-accent-primary);
  color: #0b1020;
}

#search-form button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent) inset;
}

.filter label {
  cursor: pointer;
  display: flex;
  align-items: center;
  font-size: .9rem;
  margin-bottom: .75rem;
  color: var(--color-text-secondary);
  transition: color var(--transition-fast);
}

.filter label:hover {
  color: var(--color-text-primary);
}

.filter input[type="checkbox"] {
  appearance: none;
  margin-right: .75rem;
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-sm);
  background: var(--color-surface-inset);
  cursor: pointer;
  position: relative;
  transition: all var(--transition-fast);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}

.filter input[type="checkbox"]::before {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  color: #0b1020;
  font-size: 13px;
  font-weight: 900;
  transform: translate(-50%, -50%) scale(0);
  transition: transform var(--transition-fast);
}

.filter input[type="checkbox"]:checked {
  background: var(--color-accent-primary);
  border-color: var(--color-accent-primary);
}

.filter input[type="checkbox"]:checked::before {
  transform: translate(-50%, -50%) scale(1);
}

.filter input[type="checkbox"]:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

.dropdown-search {
  width: 100%;
  margin-bottom: .6rem;
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  padding: .65rem .8rem;
  font-size: .9rem;
  outline: none;
}

.project-type-dropdown,
.country-dropdown {
  width: 100%;
  min-height: 240px;
  max-height: 240px;
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  padding: .25rem;
  overflow-y: auto;
}

.project-type-dropdown option,
.country-dropdown option {
  color: var(--color-text-secondary);
  padding: .5rem .6rem;
  border-radius: var(--radius-sm);
  outline: none;
}

.project-type-dropdown option:hover,
.country-dropdown option:hover {
  background: var(--color-surface-raised);
  color: var(--color-text-primary);
}

.project-type-dropdown option:checked,
.country-dropdown option:checked {
  background: var(--color-accent-primary);
  color: #061124;
}

#selected-project-types,
#selected-countries {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

#selected-project-types:not(:empty),
#selected-countries:not(:empty) {
  margin: .5rem 0 1rem;
}

.selected-filter {
  display: inline-flex;
  align-items: center;
  padding: .28rem .28rem .28rem .65rem;
  font-size: .78rem;
  background: linear-gradient(180deg, #60a5fa, #4f8ff0);
  border-radius: var(--radius-full);
  color: #061124;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(96, 165, 250, 0.25);
}

.remove-filter {
  margin-left: .45rem;
  cursor: pointer;
  background: rgba(6, 17, 36, 0.22);
  color: #fff;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  font-size: 12px;
  line-height: 18px;
  text-align: center;
  font-weight: 900;
  border: none;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.remove-filter:hover {
  background: rgba(6, 17, 36, 0.35);
  transform: rotate(8deg);
}

.remove-filter:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

.reset-filters {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  padding: .85rem;
  font-size: .95rem;
  font-weight: 800;
  text-align: center;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #ef4444, #dc2626);
  border: 1px solid rgba(0, 0, 0, 0.2);
  color: #fff;
  cursor: pointer;
  transition: transform var(--transition-fast), filter var(--transition-fast);
  box-shadow: 0 12px 26px rgba(220, 38, 38, 0.35);
}

.reset-filters:hover {
  filter: saturate(1.1) brightness(1.05);
  transform: translateY(-1px);
}

.reset-filters:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

.filter {
  position: relative;
  /* for absolute positioning of the panel */
}

.filter-content,
.filter .reset-filters {
  transition: opacity 0.2s ease-in-out, visibility 0.2s;
}

#project-info-panel {
  position: absolute;
  inset: 0;
  display: none;
  /* Hidden by default */
  flex-direction: column;
  overflow: hidden;
  /* Using the same background as the filter panel */
  background: var(--color-surface-glass-strong);
}

/* Toggling state on the main container */
.filter-container.project-info-active .filter-content,
.filter-container.project-info-active .reset-filters {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.filter-container.project-info-active #project-info-panel {
  display: flex;
}

/* ==========================================================================
5) Map UI Controls & Overlays
========================================================================== */
#map-switch {
  padding: .55rem 1rem;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), var(--shadow-geomorphic-inset);
  /* subtle geomorphic */
  color: var(--color-text-interactive);
  font-weight: 700;
  letter-spacing: .02em;
}

#map-switch:focus-within {
  box-shadow: var(--shadow-glow-accent);
}

.map-tool-container {
  position: absolute;
  right: 10px;
  z-index: var(--z-map-controls);
  background: transparent !important;
}

#layers-button {
  top: 4.8rem;
}

#ruler-button {
  top: 7.8rem;
}

#timeline-button {
  top: 10.8rem;
}

#compare-button {
  top: 13.8rem;
}

#pixel-analyzer-button {
  top: 16.8rem;
}

.map-tool-button {
  background: rgba(24, 33, 52, 0.92);
  border-radius: 50%;
  border: 3px solid var(--color-border-secondary) !important;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  outline: none;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), inset 0 -2px 0 rgba(255, 255, 255, 0.05);
  transition: transform .12s ease, background-color .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.map-tool-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45), inset 0 -2px 0 rgba(255, 255, 255, 0.07);
}

.map-tool-button:active {
  transform: translateY(0);
}

.map-tool-button:focus-visible {
  box-shadow: var(--shadow-glow-accent);
  border-color: rgba(96, 165, 250, 0.6) !important;
}

.map-tool-button img {
  width: 20px;
  height: 20px;
  filter: invert(.9);
  transition: filter .2s ease;
}

.map-tool-container:not(.active) .map-tool-button:hover {
  background: rgba(37, 53, 86, 1);
}

.map-tool-container.active .map-tool-button {
  background: radial-gradient(120% 140% at 50% 30%, #fde047 0%, #f59e0b 45%, #f97316 100%);
  box-shadow: 0 0 18px rgba(255, 200, 0, 0.7), 0 10px 28px rgba(0, 0, 0, 0.6);
  border-color: rgba(255, 200, 0, 0.55) !important;
}

.map-tool-container.active .map-tool-button img {
  filter: none;
}

.switch-label {
  display: flex;
  align-items: center;
  gap: .75rem;
  color: var(--color-text-secondary);
  font-size: .82rem;
  white-space: nowrap;
}

.switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: linear-gradient(180deg, #1b2640, #121a2c);
  border: 1px solid var(--color-border-primary);
  transition: var(--transition-normal);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, 0.25);
}

.slider::before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 4px;
  background: linear-gradient(180deg, #9aa7c2, #eaf0ff);
  transition: var(--transition-normal);
  border-radius: var(--radius-full);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.35);
}

input:checked+.slider {
  background: linear-gradient(180deg, #4f8ff0, #3578e6);
  border-color: rgba(96, 165, 250, 0.8);
  box-shadow: 0 0 20px rgba(96, 165, 250, 0.28);
}

input:checked+.slider::before {
  background: #fff;
  transform: translateX(18px);
}

.slider.round {
  border-radius: var(--radius-full);
}

.switch input:focus-visible+.slider {
  box-shadow: var(--shadow-glow-accent);
}

#year-selectors {
  position: absolute;
  top: 20rem;
  right: 5rem;
  z-index: var(--z-map-controls);
  display: none;
  flex-direction: column;
  gap: .5rem;
  color-scheme: dark;
}

#year-selectors select {
  background: var(--color-surface-inset);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  padding: .35rem .5rem;
}

#year-selectors select option {
  background: var(--color-bg-deep);
}

#mapLinkBubble {
  position: absolute;
  top: 23.8rem;
  right: 5rem;
  z-index: var(--z-map-controls);
  display: none;
  padding: 10px;
  border-radius: 15px;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-primary);
  max-width: 170px;
  word-wrap: break-word;
  font-size: .84rem;
  color: var(--color-text-secondary);
}

#mapLinkBubble a {
  color: var(--color-accent-primary);
}

#coordinatesDisplay {
  /* Positioning & Centering (from first version, and common properties) */
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-floating-ui);

  /* Styling (from second version) */
  padding: .45rem .8rem;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  /* For Safari compatibility */
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md), var(--shadow-geomorphic-inset);
  color: var(--color-text-primary);
}

#coordinatesDisplay:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

#geojson-slider-container {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  display: none;
  width: 220px;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 12px;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md), var(--shadow-geomorphic-inset);
  z-index: 800;
  /* subtle geomorphic */
}

#geojson-slider-container label {
  display: block;
  text-align: center;
  margin-bottom: .6rem;
  font-weight: 700;
  color: var(--color-text-secondary);
  font-size: .84rem;
}

#geojson-opacity-slider {
  width: 100%;
  accent-color: var(--color-accent-primary);
}

#mapDataLegend {
  position: absolute;
  bottom: 4rem;
  left: 1rem;
  width: 420px;
  display: none;
  padding: 1rem;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md), var(--shadow-geomorphic-inset);
  /* subtle geomorphic */
}

#indicatorTitle {
  font-weight: 800;
  letter-spacing: .01em;
  color: var(--color-text-primary);
  margin-bottom: .55rem;
}

#gradientBar {
  height: 20px;
  border-radius: 3px;
  border: 1px solid var(--color-border-primary);
  opacity: .9;
}

#legendValues {
  font-size: .8rem;
  margin-top: .28rem;
  color: var(--color-text-secondary);
  position: relative;
}

#midValue {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

#maxValue {
  float: right;
}

#text-bubbles-container {
  position: absolute;
  bottom: 0;
  left: 0;
  z-index: 850;
}

.text-bubble {
  position: absolute;
  z-index: 1001;
  background: var(--color-bg-deep);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  padding: .55rem .8rem;
  color: var(--color-text-interactive);
  font-weight: 800;
  font-size: .84rem;
  box-shadow: var(--shadow-md);
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

/* ==========================================================================
6) Layers Panel  (Typography sized down to v2 specs)
========================================================================== */
#layer-controls {
  position: absolute;
  top: 1rem;
  right: 6rem;
  z-index: var(--z-map-controls);
  width: 370px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  display: none;
  color-scheme: dark;
  padding: .5rem;
}

.dropdown-section {
  background: rgba(6, 9, 14, 1.0);
  border-radius: var(--radius-md);
  margin-bottom: .65rem;
  border: 1px solid var(--color-border-secondary);
  box-shadow: var(--shadow-sm);
}

.dropdown-title {
  font-weight: 800;
  font-size: .6rem;
  /* v2 size */
  padding: .6rem 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background-color var(--transition-fast);
}

.dropdown-title:hover {
  background: rgba(255, 255, 255, 0.06);
}

.dropdown-title:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent) inset;
}

.dropdown-title img {
  width: 18px;
  height: 18px;
  margin-right: .75rem;
  filter: invert(.9);
}

.dropdown-arrow {
  transition: transform var(--transition-normal);
}

.dropdown-title.active .dropdown-arrow {
  transform: rotate(180deg);
}

.dropdown-content {
  display: none;
  padding: 0 1rem .85rem;
  border-top: 1px solid var(--color-border-secondary);
}

.dropdown-title.active+.dropdown-content {
  display: block;
}

.dropdown-content .switch-label {
  padding: .35rem 0;
  font-size: .52rem;
  /* v2 size / MODIFIED to shorten height */
  border-bottom: 1px solid var(--color-border-secondary);
}

.dropdown-content .switch-label:last-child {
  border-bottom: none;
}

.dropdown-content .label-container {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-grow: 1;
}

.label-container label {
  transition: color var(--transition-fast);
}

.label-container:hover label {
  color: var(--color-text-primary);
}

.label-container a img {
  width: 14px;
  height: 14px;
  opacity: .7;
  transition: opacity var(--transition-fast);
}

.label-container a:hover img {
  opacity: 1;
}

.search-bar-wrapper,
.indicator-dropdown,
.year-input-wrapper {
  margin: .55rem 0;
}

.search-bar {
  display: flex;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-sm);
  background: var(--color-surface-inset);
  overflow: hidden;
}

#species-search,
#start-year-input,
#end-year-input,
#indicatorDropdown,
#yearDropdown,
#hexagon-attribute-dropdown,
#hexagon-time-dropdown {
  background: transparent;
  border: none;
  color: var(--color-text-primary);
  padding: .4rem .7rem;
  font-size: .52rem;
  /* v2 size / MODIFIED to shorten height */
  outline: none;
}

.search-bar input[type="text"] {
  flex-grow: 1;
}

.search-bar button {
  background: var(--color-surface-raised);
  border: none;
  border-left: 1px solid var(--color-border-primary);
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 0 .75rem;
  transition: background-color var(--transition-fast);
}

.search-bar button:hover {
  background: var(--color-accent-primary);
  color: #061124;
}

.search-bar button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent) inset;
}

#species-search::placeholder {
  color: var(--color-text-tertiary);
}

#autocomplete-dropdown {
  position: absolute;
  background: #121a2c;
  border: 1px solid var(--color-border-primary);
  z-index: 1001;
  max-height: 160px;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  border-radius: var(--radius-md);
}

.autocomplete-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: .55rem;
  /* v2 size */
  color: var(--color-text-secondary);
}

.autocomplete-item:hover {
  background: var(--color-accent-primary);
  color: #061124;
}

select,
input[type="number"] {
  width: 100%;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-sm);
  background: var(--color-surface-inset);
  color: var(--color-text-primary);
}

select option {
  background: var(--color-bg-primary);
}

.indicator-dropdown,
.year-input-wrapper {
  display: flex;
  gap: .5rem;
  align-items: center;
}

.year-input-wrapper label {
  color: var(--color-text-secondary);
  font-size: .55rem;
  /* v2 size */
}

/* ==========================================================================
7) Pixel Analyzer UI
========================================================================== */
#pixel-analyzer-tool-ui {
  position: fixed;
  top: 1rem;
  left: 1rem;
  width: 390px;
  max-height: calc(100vh - 2rem);
  z-index: var(--z-floating-ui);
}

#pixelAnalysisResultsArea {
  background: var(--color-surface-glass-strong) !important;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-primary) !important;
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--color-text-secondary);
  display: none;
  overflow-y: auto;
  max-height: inherit;
  box-shadow: var(--shadow-md);
}

#pixelAnalysisMessage {
  background: var(--color-surface-inset) !important;
  border: 1px solid var(--color-border-primary) !important;
  color: var(--color-text-primary) !important;
  border-radius: var(--radius-sm);
  padding: .75rem;
  font-size: .9rem;
  margin-bottom: 1rem;
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.03);
}

#pixel-analysis-controls {
  background: none !important;
  border-bottom: 1px solid var(--color-border-primary) !important;
  padding-bottom: 1rem;
  margin-bottom: 1rem;
  text-align: center;
}

#pixel-analysis-controls label {
  font-size: .86rem;
  vertical-align: middle;
  color: var(--color-text-interactive) !important;
}

#highlightColorPicker {
  vertical-align: middle;
  background: none;
  border: 1px solid var(--color-border-primary);
  padding: 2px;
  width: 46px;
  height: 26px;
  cursor: pointer;
  border-radius: 8px;
}

#highlightColorPicker:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

#rerunAnalysisButton {
  background: var(--color-surface-raised) !important;
  border: 1px solid var(--color-border-primary) !important;
  color: var(--color-text-interactive);
  padding: .3rem .7rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
  vertical-align: middle;
  font-weight: 700;
}

#rerunAnalysisButton:hover {
  background: var(--color-accent-primary) !important;
  color: #061124 !important;
  transform: translateY(-1px);
}

#rerunAnalysisButton:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

#pixelAnalysisChartCanvasWrapper {
  background: var(--color-surface-inset);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

#pixelAnalysisStatsContainer h4 {
  color: var(--color-text-primary);
  margin-bottom: .5rem;
  font-weight: 800;
}

#pixelAnalysisStatsContainer p {
  font-size: .86rem;
  margin-bottom: .25rem;
}

#pixelAnalysisStatsContainer strong {
  color: var(--color-text-primary);
  font-weight: 700;
}

#pixelAnalysisTableContainer {
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  overflow: hidden;
  max-height: 300px;
  overflow-y: auto;
  margin-top: 1rem;
  box-shadow: var(--shadow-sm);
}

#pixelAnalysisTableContainer table {
  font-size: .86rem;
  width: 100%;
  border-collapse: collapse;
}

#pixelAnalysisTableContainer th {
  background: var(--color-surface-raised) !important;
  border: none !important;
  border-bottom: 1px solid var(--color-border-primary) !important;
  padding: .55rem .7rem;
  text-align: left;
  font-weight: 800;
  color: var(--color-text-primary);
}

#pixelAnalysisTableContainer td {
  border: none;
  border-top: 1px solid var(--color-border-primary);
  padding: .5rem .65rem;
  vertical-align: middle;
  color: var(--color-text-secondary);
}

#pixelAnalysisTableContainer tr:first-child td {
  border-top: none;
}

#pixelAnalysisTableBody .swatch {
  width: 16px;
  height: 16px;
  border-radius: var(--radius-sm);
  display: inline-block;
  vertical-align: middle;
  border: 1px solid var(--color-border-primary);
}

/* ==========================================================================
8) Popups & Modals
========================================================================== */
#popup {
  position: fixed;
  top: 5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-overlay);
  width: 90%;
  max-width: 460px;
  pointer-events: none;
}

.popup-message {
  background: linear-gradient(180deg, #fde047, #facc15);
  color: #101010;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-weight: 800;
  text-align: center;
  opacity: 0;
  transition: opacity .5s ease-in-out, transform .5s ease;
  transform: translateY(-6px);
}

#popup.show-popup .popup-message {
  opacity: 1;
  transform: translateY(0);
}

#overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, .84);
  backdrop-filter: blur(10px);
  z-index: var(--z-overlay);
  display: none;
  justify-content: center;
  align-items: center;
}

#overlay>div {
  color: var(--color-text-primary);
  font-size: clamp(2rem, 10vw, 4.2rem);
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: .22em;
  animation: pulse-text 2s infinite ease-in-out;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

@keyframes pulse-text {

  0%,
  100% {
    opacity: .85;
  }

  50% {
    opacity: 1;
  }
}

/* overlay1 — adopt v2 sizing ONLY */
#overlay1 {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: var(--z-floating-ui);
  background: var(--color-accent-highlight);
  color: var(--color-bg-deep);
  padding: .5rem 1rem;
  text-align: center;
  font-weight: 700;
  font-size: .8rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
}

.modal {
  display: none;
  position: fixed;
  z-index: var(--z-modal);
  inset: 0;
  overflow: auto;
  background: rgba(4, 7, 12, .86);
  backdrop-filter: blur(10px);
}

.modal-content {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)), var(--color-bg-primary);
  margin: 5% auto;
  padding: 2rem;
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 80%;
  max-width: 860px;
  color: var(--color-text-secondary);
  text-align: left;
}

.close {
  color: var(--color-text-tertiary);
  float: right;
  font-size: 28px;
  font-weight: 800;
}

.close:hover,
.close:focus {
  color: var(--color-text-primary);
  text-decoration: none;
  cursor: pointer;
}

.modal-content h1,
.modal-content h2,
.modal-content h3 {
  color: var(--color-text-primary);
  border-bottom: 1px solid var(--color-border-primary);
  padding-bottom: .6rem;
  margin-bottom: 1rem;
}

.modal-content p,
.modal-content li {
  line-height: 1.8;
}

.modal-content ul,
.modal-content ol {
  padding-left: 1.5rem;
}

.modal-content .video-container {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding-top: 56.25%;
  margin-bottom: 2rem;
  border-radius: var(--radius-md);
  background: var(--color-bg-deep);
  box-shadow: var(--shadow-sm);
}

.modal-content .video-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal-content p,
.modal-content li {
  font-size: .98rem;
  color: var(--color-text-secondary);
  margin-bottom: 1rem;
}

.modal-content a {
  color: var(--color-accent-primary);
  font-weight: 700;
  text-decoration: none;
  transition: all var(--transition-fast);
}

.modal-content a:hover {
  text-decoration: underline;
  color: #fff;
}

/* ==========================================================================
   9) Project Information Panel (Replaces Marker Popups) - FINAL FIXED
   ========================================================================== */

/* --- Leaflet overrides to hide default popup chrome --- */
.leaflet-popup-content-wrapper {
  background: transparent;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
}

.leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
}

.leaflet-popup-tip-container,
.leaflet-popup-close-button {
  display: none;
}


/* --- Main Wrapper in the side panel --- */
.project-info-wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  /* Deep Navy/Slate Theme Base */
  background-color: #020617; 
  color: #f1f5f9;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 14px;
}

/* --- Panel Header (Title + Close Button) --- */
.panel-main-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 1rem 1.25rem;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
  z-index: 20;
}

.panel-title {
  font-family: var(--font-display, sans-serif);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.4;
  margin: 0;
  padding-right: 1rem;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.8); 
}

.panel-close-button {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #94a3b8;
  height: 32px;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-close-button:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.3);
}

/* --- Panel Tabs --- */
.panel-tabs {
  display: flex;
  gap: 0;
  background: #0f172a; /* Slate 900 */
  padding: 0 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.popup-tab-button {
  position: relative;
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 1rem 1rem;
  cursor: pointer;
  background: transparent;
  border: none;
  color: #64748b; /* Slate 500 */
  transition: color 0.2s ease;
}

.popup-tab-button:hover {
  color: #cbd5e1;
}

.popup-tab-button.current-tab {
  color: #38bdf8; /* Sky 400 */
}

.popup-tab-button.current-tab::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: #38bdf8;
  box-shadow: 0 -2px 8px rgba(56, 189, 248, 0.5);
}

/* --- Panel Content Area --- */
.panel-content-area {
  flex-grow: 1;
  position: relative;
  overflow: hidden; 
  background: #020617;
}

/* --- Custom Scrollbar Styling --- */
.project-info-content::-webkit-scrollbar,
.transactions-content .dataTables_scrollBody::-webkit-scrollbar,
.proximity-table-container::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.project-info-content::-webkit-scrollbar-track,
.transactions-content .dataTables_scrollBody::-webkit-scrollbar-track,
.proximity-table-container::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.5);
}

.project-info-content::-webkit-scrollbar-thumb,
.transactions-content .dataTables_scrollBody::-webkit-scrollbar-thumb,
.proximity-table-container::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.project-info-content::-webkit-scrollbar-thumb:hover,
.transactions-content .dataTables_scrollBody::-webkit-scrollbar-thumb:hover,
.proximity-table-container::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   TAB 1: PROJECT INFO CONTENT
   ========================================================================== */

.project-info-content {
  position: absolute;
  inset: 0;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  gap: 1.5rem;
}

/* Header inside content (Logo/SDGs) */
.popup-main-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 0.5rem;
}

.header-right-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.5rem;
}

.registry-logo-container {
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  padding: 4px 8px;
}

.registry-logo {
  height: 24px;
  width: auto;
  display: block;
}

.sdg-container {
  display: flex;
  gap: 4px;
}

.sdg-icons img {
  width: 28px;
  height: 28px;
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

/* Data Grid (Details) */
.details-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem 1.5rem;
  align-items: baseline;
  background: rgba(15, 23, 42, 0.4);
  padding: 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.details-list dt {
  grid-column: 1;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
}

.details-list dd {
  grid-column: 2;
  margin: 0;
  font-size: 0.9rem;
  color: #e2e8f0;
  font-weight: 500;
  word-break: break-word;
}

/* Chart Container */
.chart {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
  min-height: 250px;
}

.chart .plot-container, .chart .svg-container {
  width: 100% !important;
  height: 100% !important;
}

/* Description Accordion */
.description-details {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: #0f172a;
}

.description-details summary {
  padding: 1rem;
  cursor: pointer;
  font-weight: 600;
  color: #e2e8f0;
  list-style: none;
  display: flex;
  align-items: center;
}

.description-details summary::before {
  content: '▶';
  font-size: 0.6em;
  margin-right: 0.75rem;
  color: #94a3b8;
  transition: transform 0.2s;
}

.description-details[open] summary::before {
  transform: rotate(90deg);
}

.description-details[open] summary {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.description-details p {
  padding: 1rem;
  margin: 0;
  line-height: 1.6;
  color: #cbd5e1;
  font-size: 0.9rem;
}

/* Links Footer */
.popup-links {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 1rem;
  margin-top: 1rem;
}

.popup-links a {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}

.popup-links a:hover {
  text-decoration: underline;
  text-shadow: 0 0 8px rgba(56, 189, 248, 0.6);
}

/* ==========================================================================
   TAB 2: TRANSACTIONS (FIXED WIDTH & DARK THEME FORCE)
   ========================================================================== */

.transactions-content {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
  width: 100%;
  background-color: #020617; /* Force dark bg on container */
}

/* Structure */
.transactions-content .dataTables_wrapper {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.transactions-content .dataTables_scroll {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  height: 100%;
  overflow: hidden;
}

.transactions-content .dataTables_scrollHead {
  flex-shrink: 0;
  background-color: #0f172a !important;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.transactions-content .dataTables_scrollBody {
  flex-grow: 1;
  height: auto !important;
  max-height: 100% !important;
  overflow-y: auto !important;
  overflow-x: hidden !important; /* Disable horizontal scroll */
  background-color: #020617 !important; /* Ensure no white void */
}

/* Table Style & Color Fixes */
.transaction-table {
  width: 100% !important;
  table-layout: fixed; /* Force columns to fit within the viewport width */
  border-collapse: collapse;
  margin: 0 !important;
  background-color: transparent !important;
}

/* Header Cells */
.transaction-table th {
  background-color: #0f172a !important; /* Dark header */
  color: #94a3b8 !important; /* Muted text */
  font-size: 0.7rem; /* Smaller font to fit */
  text-transform: uppercase;
  padding: 12px 6px !important; /* Tighter padding */
  text-align: left;
  border: none !important;
  font-weight: 700;
  white-space: normal; /* Allow header text to wrap if absolutely necessary */
  overflow: hidden;
}

/* Body Rows & Cells */
.transaction-table tbody tr {
  background-color: #020617 !important; /* Override white defaults from library */
}

.transaction-table tbody tr.odd,
.transaction-table tbody tr.even,
.transaction-table tbody tr:nth-child(odd),
.transaction-table tbody tr:nth-child(even) {
  background-color: #020617 !important; /* Force dark on stripes */
}

.transaction-table tbody tr:hover > td {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #fff !important;
}

.transaction-table td {
  padding: 10px 6px !important; /* Tighter padding for width fit */
  font-size: 0.8rem;
  color: #cbd5e1 !important; /* Readable light gray text */
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
  
  /* Text Wrapping Logic */
  white-space: normal !important; /* Allow text to wrap lines */
  word-wrap: break-word !important; /* Break long words if needed */
  overflow-wrap: break-word !important;
}

/* Hide Pagination/Filter controls */
.transactions-content .dataTables_info,
.transactions-content .dataTables_paginate,
.transactions-content .dataTables_length,
.transactions-content .dataTables_filter {
  display: none;
}

/* ==========================================================================
   TAB 3: PROXIMITY
   ========================================================================== */

.proximity-content {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.proximity-table-container {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
}

.proximity-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.proximity-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #0f172a;
  color: #94a3b8;
  font-size: 0.75rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 12px 10px;
  text-align: left;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1);
}

.proximity-table td {
  padding: 10px;
  font-size: 0.85rem;
  color: #cbd5e1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  vertical-align: middle;
}

/* Columns */
.col-dist { width: 15%; font-family: monospace; color: #64748b; }
.col-source { width: 20%; }
.col-type { width: 20%; font-size: 0.8rem; }
.col-title { width: 30%; font-weight: 500; }
.col-link { width: 15%; text-align: center; }

/* Interactive Rows */
.proximity-row {
  cursor: pointer;
  transition: background 0.1s;
}

.proximity-row:hover {
  background-color: rgba(56, 189, 248, 0.08); /* Faint blue hover */
}

/* Highlighted Row */
.proximity-row.highlighted {
  background-color: rgba(234, 179, 8, 0.15); /* Yellow/Gold tint */
  border-left: 3px solid #eab308;
}

.proximity-row.highlighted td {
  color: #fefce8;
}

/* Source Badges */
.proximity-source-badge {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  color: #fff;
  white-space: nowrap;
}

.source-ejatlas { background-color: #3b82f6; } /* Blue */
.source-envsociety { background-color: #22c55e; } /* Green */
.source-gdacs { background-color: #ef4444; } /* Red */
.source-landmatrix { background-color: #f59e0b; } /* Orange */

.proximity-link {
  color: #38bdf8;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.75rem;
  border: 1px solid rgba(56, 189, 248, 0.3);
  padding: 2px 6px;
  border-radius: 4px;
}

.proximity-link:hover {
  background: rgba(56, 189, 248, 0.1);
}

/* === Proximity Map Marker (Solid, High Visibility) === */
.proximity-event-marker {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #ffffff;
  box-shadow: 0 0 4px rgba(0,0,0,0.5); /* Static shadow */
  background-color: #888;
}

/* Specific Marker Colors */
.proximity-event-marker.source-ejatlas { background-color: #3b82f6; box-shadow: 0 0 8px rgba(59, 130, 246, 0.8); }
.proximity-event-marker.source-envsociety { background-color: #22c55e; box-shadow: 0 0 8px rgba(34, 197, 94, 0.8); }
.proximity-event-marker.source-gdacs { background-color: #ef4444; box-shadow: 0 0 8px rgba(239, 68, 68, 0.8); }
.proximity-event-marker.source-landmatrix { background-color: #f59e0b; box-shadow: 0 0 8px rgba(245, 158, 11, 0.8); }

.proximity-event-label {
  background-color: #0f172a;
  color: #fff;
  border: 1px solid #334155;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.custom-icon {
  background: none !important;
  border: none !important;
}

/* ==========================================================================
10) Misc & Leaflet Specifics
========================================================================== */
.pulse-circle {
  border: 2px solid var(--color-accent-highlight);
  animation: none;
  opacity: 0;
}

div.leaflet-marker-icon:hover>.pulse-circle {
  animation: pulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(.8);
    opacity: .7;
  }

  70% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }

  100% {
    opacity: 0;
  }
}

#year-slider {
  position: absolute;
  bottom: 80px;
  width: 80%;
  left: 10%;
  z-index: var(--z-map-controls);
  display: none;
}

#year-filter-textbox {
  position: absolute;
  bottom: -5px;
  left: -12%;
  font-weight: 800;
  display: none;
  padding: .8rem;
  text-align: center;
  width: 150px;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  color: var(--color-text-primary);
}

/* noUiSlider theming */
.noUi-target {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-full);
  box-shadow: none;
  height: 8px;
}

.noUi-connect {
  background: linear-gradient(90deg, #60a5fa, #3b82f6);
  height: 8px;
}

.noUi-handle {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  border: 3px solid var(--color-accent-primary);
  background: #0b111a;
  box-shadow: 0 4px 12px rgba(96, 165, 250, 0.35);
  right: -11px;
  top: -8px;
  cursor: grab;
}

.noUi-handle:focus {
  outline: none;
}

.noUi-handle:active {
  cursor: grabbing;
}

.noUi-handle::before,
.noUi-handle::after {
  display: none;
}

.noUi-pips-horizontal {
  padding: 12px 0;
  height: auto;
  top: 16px;
  left: 0;
  width: 100%;
  color: var(--color-text-secondary);
}

.noUi-marker-horizontal {
  height: 8px;
  background: var(--color-text-tertiary);
}

.noUi-value-horizontal {
  transform: translate(-50%, 150%);
}

.legend {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--color-text-primary);
  z-index: var(--z-floating-ui);
  font-size: .86rem;
  line-height: 1.55;
  box-shadow: var(--shadow-md), var(--shadow-geomorphic-inset);
  /* subtle geomorphic */
}

.legend.no-background {
  background: transparent;
  border: none;
  backdrop-filter: none;
  box-shadow: none;
}

.legend.no-border {
  border: none;
}

.legend h2 {
  font-size: 1.12rem;
  margin-bottom: .6rem;
  border-bottom: 1px solid var(--color-border-primary);
  padding-bottom: .5rem;
}

.legend-image {
  background: transparent !important;
}

#legend-button {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md), var(--shadow-geomorphic-inset);
  /* subtle geomorphic */
  padding: .65rem 1.25rem;
  font-weight: 800;
  font-size: .92rem;
  letter-spacing: .02em;
  color: var(--color-text-interactive);
  cursor: pointer;
  transition: transform var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast);
  z-index: var(--z-map-controls);
}

#legend-button:hover {
  transform: translateY(-2px);
  border-color: var(--color-accent-primary);
  color: #fff;
  box-shadow: var(--shadow-lg), var(--shadow-geomorphic-inset);
}

#legend-button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

.project-count-display,
.project-details-display {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: var(--color-surface-glass-strong);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md), var(--shadow-geomorphic-inset);
  padding: 1rem;
  z-index: var(--z-floating-ui);
  width: 280px;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  color: var(--color-text-secondary);
}

.project-count-display span,
.project-details-display strong {
  color: var(--color-text-primary);
}

.project-details-display button {
  width: 100%;
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-secondary);
  color: var(--color-text-secondary);
  text-align: left;
  padding: .45rem .65rem;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background-color var(--transition-fast), border-color var(--transition-fast), transform var(--transition-fast), color var(--transition-fast);
  font-weight: 700;
}

.project-details-display button:hover {
  background-color: var(--color-accent-primary);
  border-color: var(--color-accent-primary);
  color: #061124;
  transform: translateX(1px);
}

.project-details-display button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

.project-details-display button b {
  color: inherit;
}

.no-data {
  font-size: 1.2rem;
  text-align: center;
  color: var(--color-text-tertiary);
  padding: 2rem;
}

.hidden,
.hide-table {
  display: none !important;
}

.pulse-circle {
  border: 2px solid var(--color-accent-highlight);
  animation: none;
  opacity: 0;
}

div.leaflet-marker-icon:hover>.pulse-circle {
  animation: pulse 2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

@keyframes pulse {
  0% {
    transform: translate(-50%, -50%) scale(.8);
    opacity: .7;
  }

  70% {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
  }

  100% {
    opacity: 0;
  }
}

/* --- START: DYNAMIC styles for selected marker (V6 - Even Lower) --- */

/* The wrapper holds the image and will be our animation target */
.marker-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease-out;
}

/* When the parent Leaflet icon is selected... */
.custom-icon.selected .marker-wrapper {
  position: relative;
  animation: pulse-icon 2.5s infinite cubic-bezier(0.45, 0, 0.55, 1);
  z-index: 1;
}

/* Create the "sonar ping" effect using pseudo-elements on the wrapper */
.custom-icon.selected .marker-wrapper::before,
.custom-icon.selected .marker-wrapper::after {
  content: '';
  position: absolute;
  left: 50%;

  /* 
      THE FIX: Set a value > 100% to push the origin point
      significantly below the icon itself.
    */
  top: 120%;

  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  border-radius: 50%;

  background-color: rgba(56, 189, 248, 0.3);
  box-shadow: 0 0 12px 6px rgba(14, 165, 233, 0.8),
    0 0 30px 10px rgba(37, 99, 235, 0.6);

  z-index: -1;
  animation: sonar-ping 2.5s infinite cubic-bezier(0, 0, 0.2, 1);
}

/* Stagger the second ring's animation */
.custom-icon.selected .marker-wrapper::after {
  animation-delay: -1.25s;
}

/* Keyframe for the icon's "breathing" pulse */
@keyframes pulse-icon {
  0% {
    transform: scale(1.1);
  }

  50% {
    transform: scale(1.25);
  }

  100% {
    transform: scale(1.1);
  }
}

/* Keyframe for the expanding and fading sonar ping */
@keyframes sonar-ping {
  0% {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 1;
  }

  100% {
    transform: translate(-50%, -50%) scale(3.5);
    opacity: 0;
  }
}

/* --- END: Added styles for selected marker --- */


#year-slider {
  position: absolute;
  bottom: 80px;
  width: 80%;
  left: 10%;
  z-index: var(--z-map-controls);
  display: none;
}

/* ==========================================================================
11) DataTables - Dark Theme
========================================================================== */
.dataTables_wrapper {
  color: var(--color-text-secondary);
}

.dataTables_length select,
.dataTables_filter input {
  background: var(--color-surface-raised);
  border: 1px solid var(--color-border-primary);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  margin: 0 .5rem;
  padding: .45rem .6rem;
  box-shadow: inset 0 -2px 0 rgba(255, 255, 255, 0.03);
}

#data-table {
  border-collapse: collapse;
  width: 100% !important;
  margin-top: 1.5rem;
}

#data-table th {
  padding: .85rem 1rem;
  background: #0f1726;
  color: var(--color-text-primary);
  font-weight: 800;
  border-bottom: 2px solid var(--color-border-primary);
  position: sticky;
  top: 0;
  z-index: 1;
}

#data-table tbody tr {
  background: #121a2b;
  border-bottom: 1px solid var(--color-border-secondary);
}

#data-table tbody tr:hover {
  background: #0e1524;
}

#data-table td {
  padding: 1rem;
  color: var(--color-text-primary);
  border: none;
}

#data-table tbody tr.child td {
  background: #10192a;
}

.child-description {
  padding: 1.25rem;
  border-left: 3px solid var(--color-accent-primary);
  color: var(--color-text-secondary);
  font-size: .92rem;
  line-height: 1.7;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02));
  border-radius: 0 8px 8px 0;
}

td.dt-control {
  cursor: pointer;
  text-align: center;
}

td.dt-control::before {
  content: '+';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #0f1726;
  color: var(--color-text-secondary);
  font-weight: 900;
  transition: all var(--transition-fast);
  border: 1px solid var(--color-border-primary);
}

tr.dt-hasChild td.dt-control::before {
  content: '−';
  background: var(--color-accent-primary);
  color: #061124;
  border-color: transparent;
  box-shadow: 0 4px 10px rgba(96, 165, 250, 0.35);
}

.dataTables_info {
  padding-top: 1rem;
  font-size: .9rem;
}

.dataTables_paginate .paginate_button {
  background: #121a2b;
  border: 1px solid var(--color-border-primary);
  color: var(--color-text-secondary) !important;
  margin: 0 2px;
  border-radius: var(--radius-sm);
  transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}

.dataTables_paginate .paginate_button:hover,
.dataTables_paginate .paginate_button.current {
  background: var(--color-accent-primary);
  border-color: var(--color-accent-primary);
  color: #061124 !important;
  transform: translateY(-1px);
}

.dataTables_paginate .paginate_button:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow-accent);
}

.doc-link,
.no-doc {
  font-size: 1.2em;
  text-align: center;
  display: block;
  color: var(--color-text-secondary);
}

/* ==========================================================================
12) Responsive
========================================================================== */
@media (max-width: 1200px) {
  /* Layout is fixed-positioned; visual polish only */
}

@media (max-width: 900px) {
  #button-container {
    flex-wrap: wrap;
    justify-content: center;
    width: 92%;
    max-width: 460px;
    top: .6rem;
  }

  .large-button.unified-button {
    padding: .5rem 1rem;
    font-size: .82rem;
  }
}

@media (max-width: 600px) {
  #button-container {
    display: none;
  }

  .filter-container {
    width: 100%;
    transform: translateX(100%);
  }

  .filter-container:not(.collapsed) {
    transform: translateX(0);
  }

  .filter-toggle {
    left: -42px;
  }

  .filter-container:not(.collapsed)~#content-container #map {
    right: 100%;
  }

  #map {
    right: 0;
  }

  .map-control-right,
  #layer-controls,
  .legend,
  #legend-button {
    right: 1rem !important;
  }

  .social-icons {
    bottom: .5rem;
    left: .5rem;
  }

  #coordinatesDisplay {
    bottom: .5rem;
    right: .5rem;
  }

  #mapDataLegend {
    width: calc(100% - 2rem);
    left: 1rem;
    bottom: 3rem;
  }

  #geojson-slider-container {
    left: 1rem;
    bottom: .5rem;
    width: calc(100% - 2rem);
  }
}

/* ==========================================================================
13) A11y & Motion Preferences
========================================================================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}

@media (prefers-contrast: more) {
  :root {
    --color-border-primary: rgba(255, 255, 255, 0.28);
    --color-border-secondary: rgba(255, 255, 255, 0.2);
  }

  .unified-button,
  .filter input[type="checkbox"],
  .search-bar,
  #map-switch,
  .legend,
  .modal-content,
  .project-details-display button {
    border-width: 2px;
  }
}

/* ==========================================================================
14) Leaflet Marker/Cluster/Tooltip — FULL COPY FROM v2 (requested)
========================================================================== */
.marker-cluster {
  border-radius: 50% !important;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
  background-clip: padding-box !important;
}

.marker-cluster div {
  width: 30px !important;
  height: 30px !important;
  margin-left: 3px !important;
  margin-top: 3px !important;
  text-align: center !important;
  border-radius: 50% !important;
  font-family: var(--font-sans) !important;
  font-weight: 600 !important;
  font-size: 12px !important;
  color: #fff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
}

.marker-cluster-small {
  background-color: rgba(96, 165, 250, 0.6) !important;
  border: 2px solid rgba(96, 165, 250, 0.8) !important;
}

.marker-cluster-medium {
  background-color: rgba(59, 130, 246, 0.6) !important;
  border: 2px solid rgba(59, 130, 246, 0.8) !important;
}

.marker-cluster-large {
  background-color: rgba(37, 99, 235, 0.6) !important;
  border: 2px solid rgba(37, 99, 235, 0.8) !important;
}

.marker-cluster-small div {
  background-color: #60a5fa !important;
}

.marker-cluster-medium div {
  background-color: #3b82f6 !important;
}

.marker-cluster-large div {
  background-color: #2563eb !important;
}

.leaflet-tooltip {
  background-color: #1e40af !important;
  border: 1px solid rgba(59, 130, 246, 0.5) !important;
  border-radius: var(--radius-md) !important;
  color: #fff !important;
  padding: 4px 10px !important;
  font-size: 11px !important;
  font-weight: 600 !important;
  white-space: nowrap !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15) !important;
  background-clip: padding-box !important;
}

.leaflet-tooltip-top:before,
.leaflet-tooltip-bottom:before,
.leaflet-tooltip-left:before,
.leaflet-tooltip-right:before {
  border: none !important;
}

/* Cluster example/preview (override to v2 look) */
.cluster-marker-container {
  display: flex;
  align-items: center;
  position: relative;
  margin-left: 5px;
}

.cluster-marker-example {
  background: var(--color-accent-primary);
  color: #fff;
  font-weight: 700;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  z-index: 2;
}

.cluster-marker-background {
  background: var(--color-accent-primary);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  position: absolute;
  opacity: .3;
  z-index: 1;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.cluster-marker-text {
  margin-left: 25px;
}