/* ═══════════════════════════════════════════════════════
   CHECK HIGHEST POINT — Monica Soft Theme Adaptation
   NBAE EJ © 2026
   ═══════════════════════════════════════════════════════ */

:root {
  --color-primary:       #2C7EA0;
  --color-primary-light: #3A8FB5;
  --color-accent:        #F0955A;
  --color-accent-light:  #F4AB77;
  --color-green:         #5A9A3E;
  --color-warning:       #F5A623;
  --color-danger:        #E05252;
  --color-bg:            #F4F7FA;
  --color-surface:       #FFFFFF;
  --color-border:        #E2E8F0;
  --color-border-light:  #EAF0F5;
  --color-text:          #374151;
  --color-text-muted:    #6B7280;
  --color-text-subtle:   #9CA3AF;
  --font-family: "Inter", "Plus Jakarta Sans", "Segoe UI", Aptos, sans-serif;
}

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

html {
  height: 100%;
}
body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font-family);
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-bg);
}

/* ── HEADER ─────────────────────────────────────────── */
.main-header {
  background: linear-gradient(135deg, #2C7EA0 0%, #3A8FB5 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  height: 46px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(44,126,160,0.22);
  z-index: 200;
  position: relative;
}
.header-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 1.8px;
  text-transform: uppercase;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.btn-tower {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.14);
  color: #fff;
  cursor: default;   /* hidden menu — no hand cursor, no hover hint */
  flex-shrink: 0;
}
.btn-tower.loaded { background: rgba(255,255,255,0.92); color: #2C7EA0; }
.gcell-status {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.toolbar-group[hidden] { display: none; }
.site-label {
  background: rgba(255,255,255,0.9);
  border: none;
  box-shadow: none;
  padding: 0 4px;
  font-size: 10px;
  font-weight: 700;
  color: #1F2937;
}
.header-meta {
  font-size: 11px;
  text-align: right;
  opacity: 0.8;
  line-height: 1.4;
}

/* ── TOOLBAR ─────────────────────────────────────────── */
.toolbar {
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border-light);
  box-shadow: 0 1px 6px rgba(44,126,160,0.07);
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  flex-wrap: nowrap;
  height: 56px;
  position: relative;
  z-index: 150;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-divider {
  width: 1px;
  height: 32px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* Field label + input stack */
.field-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.field-label {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--color-text-muted);
  line-height: 1;
}

/* Lat/Lng input */
.input-latlng {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 12px;
  font-family: var(--font-family);
  color: var(--color-text);
  background: #F9FAFB;
  width: 210px;
  transition: border-color 0.15s, box-shadow 0.15s;
  height: 28px;
}
.input-latlng:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(44,126,160,0.12);
}

/* Radius slider */
.radius-slider-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.radius-track-label {
  font-size: 10px;
  color: var(--color-text-subtle);
  white-space: nowrap;
}
input[type="range"].slider-radius {
  -webkit-appearance: none;
  appearance: none;
  width: 180px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--color-accent) 0%, var(--color-accent) var(--fill, 33%), #E2E8F0 var(--fill, 33%), #E2E8F0 100%);
  outline: none;
  cursor: pointer;
}
input[type="range"].slider-radius::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent);
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(240,149,90,0.45);
  transition: transform 0.1s;
}
input[type="range"].slider-radius::-webkit-slider-thumb:hover { transform: scale(1.15); }

/* Radius number input */
.input-radius {
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 5px 6px;
  font-size: 12px;
  font-family: var(--font-family);
  color: var(--color-text);
  background: #F9FAFB;
  width: 72px;
  height: 28px;
  text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input-radius:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(44,126,160,0.12);
}


/* ── BUTTONS ─────────────────────────────────────────── */
.btn {
  border: none;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
  padding: 0 14px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  white-space: nowrap;
  line-height: 1;
}
.btn:active { transform: scale(0.97); }

.btn-browse {
  background: linear-gradient(135deg, #E05252, #C94040);
  color: #fff;
  box-shadow: 0 2px 5px rgba(224,82,82,0.28);
}
.btn-browse:hover { background: linear-gradient(135deg, #C94040, #B53535); }

.btn-autoload {
  background: linear-gradient(135deg, #5A9A3E, #72B853);
  color: #fff;
  box-shadow: 0 2px 5px rgba(90,154,62,0.28);
}
.btn-autoload:hover { background: linear-gradient(135deg, #4E8833, #65A847); }
.btn-autoload:disabled {
  background: #C5D9BC;
  box-shadow: none;
  cursor: not-allowed;
}

/* Status badges */
.status-file {
  font-size: 11px;
  color: var(--color-text-muted);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge-dem {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-dem.unloaded {
  background: rgba(245,166,35,0.12);
  color: #B87A10;
  border: 1px solid rgba(245,166,35,0.35);
}
.badge-dem.loaded {
  background: rgba(90,154,62,0.12);
  color: #3D7228;
  border: 1px solid rgba(90,154,62,0.35);
}

/* ── FIND BUTTON BAR ─────────────────────────────────── */
.find-bar {
  background: #1A1A1A;
  display: flex;
  align-items: center;
  padding: 0 16px;
  height: 44px;
  flex-shrink: 0;
  z-index: 140;
  position: relative;
  gap: 0;
  overflow: hidden;
}

/* Neighbour radius panel */
.neighbour-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: 14px;
  flex-shrink: 0;
}
.neighbour-wrap[hidden] { display: none; }
.neighbour-divider {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.18);
  margin-right: 4px;
}
.neighbour-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.65);
  white-space: nowrap;
  letter-spacing: 0.5px;
}
.neighbour-val {
  font-size: 12px;
  font-weight: 800;
  color: #F5C518;
  min-width: 38px;
  text-align: right;
  white-space: nowrap;
}
.slider-neighbour {
  -webkit-appearance: none;
  appearance: none;
  width: 120px;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, #F5C518 var(--fill, 25%), rgba(255,255,255,0.18) var(--fill, 25%));
  outline: none;
  cursor: pointer;
}
.slider-neighbour::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #F5C518;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}
.slider-neighbour::-moz-range-thumb {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: none;
  background: #F5C518;
  box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.btn-find {
  background: linear-gradient(135deg, #F5C518, #F0A500);
  color: #1A1A1A;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 0 22px;
  height: 32px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-family: var(--font-family);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(245,197,24,0.35);
}
.btn-find:hover {
  background: linear-gradient(135deg, #F0A500, #E09500);
  box-shadow: 0 3px 12px rgba(245,197,24,0.45);
}
.btn-find:active { transform: scale(0.97); }
.btn-find:disabled {
  background: #555;
  color: #999;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-gain {
  margin-left: 10px;
  background: transparent;
  color: #F5C518;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 0 16px;
  height: 32px;
  border-radius: 6px;
  border: 1.5px solid #F5C518;
  cursor: pointer;
  font-family: var(--font-family);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, color 0.15s;
}
.btn-gain:hover,
.btn-gain.active { background: #F5C518; color: #1A1A1A; }
.gain-input-wrap { margin-left: 10px; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.gain-input-wrap[hidden] { display: none; }
.input-gain { width: 260px; background: #fff; }
.btn-calc-gain {
  height: 32px;
  padding: 0 14px;
  border: none;
  border-radius: 6px;
  background: linear-gradient(135deg, #F5C518, #F0A500);
  color: #1A1A1A;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.8px;
  cursor: pointer;
  font-family: var(--font-family);
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-calc-gain:hover { background: linear-gradient(135deg, #F0A500, #E09500); }
.popup-highest.popup-gain { background: linear-gradient(135deg, #4E8833, #65A847); }

.find-status {
  margin-left: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  font-size: 11px;
  color: rgba(255,255,255,0.55);
}

/* ── MAP CONTAINER ───────────────────────────────────── */
.map-wrap {
  flex: 1 1 0;
  position: relative;
  overflow: hidden;
  min-height: 0;   /* critical for flex child to shrink below content height */
}

#map {
  width: 100%;
  height: 100%;
  min-height: 0;
}

/* ── PAGE LAYOUT ─────────────────────────────────────── */
.page-layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── LAYER CONTROL (custom) ──────────────────────────── */
.layer-control {
  position: absolute;
  top: 12px;
  right: 12px;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.18);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 6px;
  backdrop-filter: blur(4px);
}
.layer-control label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  cursor: pointer;
  user-select: none;
}
.layer-control input[type="radio"],
.layer-control input[type="checkbox"] {
  accent-color: var(--color-primary);
  cursor: pointer;
}
.layer-divider {
  height: 1px;
  background: var(--color-border-light);
  margin: 2px 0;
}
.layer-toggle {
  gap: 6px;
  flex-wrap: nowrap;
}
.contour-interval-sel {
  margin-left: 2px;
  font-size: 11px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 4px;
  background: #F9FAFB;
  cursor: pointer;
  color: var(--color-text);
}

/* Contour line labels — shared */
.contour-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
  padding: 0 !important;
}
.contour-label::before { display: none; }

/* Satellite basemap — white text with black outline */
.contour-label-sat {
  color: #fff;
  text-shadow:
    -1px -1px 0 #000,
     1px -1px 0 #000,
    -1px  1px 0 #000,
     1px  1px 0 #000,
     0    0   3px rgba(0,0,0,0.7);
}

/* Other basemaps — dark brown text with white halo */
.contour-label-dark {
  color: #5C2A00;
  text-shadow:
    -1px -1px 0 rgba(255,255,255,0.9),
     1px -1px 0 rgba(255,255,255,0.9),
    -1px  1px 0 rgba(255,255,255,0.9),
     1px  1px 0 rgba(255,255,255,0.9);
}

/* ── RESULT TOOLTIP (Leaflet popup override) ─────────── */
.leaflet-popup-content-wrapper {
  border-radius: 8px !important;
  box-shadow: 0 4px 16px rgba(44,126,160,0.22) !important;
  padding: 0 !important;
  overflow: hidden;
}
.leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
}
.popup-highest {
  background: linear-gradient(135deg, #2C7EA0, #3A8FB5);
  color: #fff;
  padding: 10px 14px;
  min-width: 230px;
  white-space: nowrap;
}
.popup-highest .popup-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  opacity: 0.8;
  margin-bottom: 6px;
}
.popup-highest .popup-section {
  font-size: 11px;
  font-weight: 700;
  margin: 7px 0 3px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.25);
}
.popup-highest .popup-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 11px;
  margin-bottom: 3px;
}
.popup-highest .popup-row .val {
  font-size: 12px;
  font-weight: 600;
}
.popup-highest .popup-elev {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(255,255,255,0.25);
  font-size: 14px;
  font-weight: 700;
  text-align: center;
}
.popup-highest .popup-dist {
  font-size: 11px;
  text-align: center;
  opacity: 0.85;
  margin-top: 2px;
}

/* Center pin popup */
.popup-center {
  background: #fff;
  color: var(--color-text);
  padding: 8px 12px;
  min-width: 160px;
}
.popup-center .popup-title {
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--color-text-muted);
  margin-bottom: 5px;
}
.popup-center .popup-row {
  font-size: 11px;
  color: var(--color-text);
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  gap: 8px;
}
.popup-center .popup-row .val {
  font-weight: 600;
  color: var(--color-primary);
}

.leaflet-popup-tip-container { display: none; }

/* ── LOADING OVERLAY ─────────────────────────────────── */
.map-loading {
  position: absolute;
  inset: 0;
  background: rgba(244,247,250,0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 900;
  backdrop-filter: blur(2px);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.map-loading.active { opacity: 1; pointer-events: all; }
.map-loading .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #EAF0F5;
  border-top-color: #2C7EA0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 10px;
}
.map-loading .loading-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── FILE INPUT HIDDEN ───────────────────────────────── */
#fileInput { display: none; }

/* ── TOAST NOTIFICATION ──────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: #1A1A1A;
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
  pointer-events: none;
  animation: toast-in 0.2s ease, toast-out 0.3s ease 2.7s forwards;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-left: 3px solid var(--color-primary);
}
.toast.success { border-left-color: var(--color-green); }
.toast.error   { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { from { opacity: 1; } to { opacity: 0; transform: translateY(-4px); } }

/* ── Map Right-Click Context Menu ─────────────────────── */
.map-ctx-menu {
  position: fixed;
  z-index: 9999;
  background: #1E2937;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
  overflow: hidden;
  min-width: 210px;
  user-select: none;
}
.ctx-coords {
  padding: 8px 14px 6px;
  font-size: 12px;
  font-weight: 700;
  color: #F5C518;
  letter-spacing: 0.4px;
  font-family: 'Courier New', monospace;
}
.ctx-divider {
  height: 1px;
  background: rgba(255,255,255,0.10);
  margin: 2px 0;
}
.ctx-item {
  padding: 8px 14px;
  font-size: 12px;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s;
}
.ctx-item:hover {
  background: rgba(245,197,24,0.15);
  color: #fff;
}

/* ── ELEVATION PROFILE PANEL ─────────────────────────── */
.elev-profile-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 300px;
  background: rgba(14, 22, 33, 0.94);
  border-top: 1px solid rgba(255,255,255,0.10);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(6px);
  animation: slideUpProfile 0.22s ease;
}
.elev-profile-panel[hidden] { display: none; }

@keyframes slideUpProfile {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.elev-profile-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 10px 3px;
  flex-shrink: 0;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.elev-profile-title {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  flex-shrink: 0;
}
.elev-profile-stats {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.elev-profile-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 13px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  line-height: 1;
  transition: background 0.12s, color 0.12s;
}
.elev-profile-close:hover { background: rgba(255,255,255,0.1); color: #fff; }

.elev-profile-chart-wrap {
  flex: 1;
  position: relative;
  min-height: 0;
  padding: 4px 8px 6px;
}
#elevProfileChart {
  width: 100% !important;
  height: 100% !important;
}

/* hint cursor on the gain line */
.gain-line-hover { cursor: pointer; }
