:root {
  --accent: #1762ff;
  --accent-dark: #0f40a6;
  --success: #23c585;
  --surface: #ffffff;
  --surface-soft: #f3f6ff;
  --text-strong: #0f1b2c;
  --card-shadow: 0 24px 60px rgba(23, 98, 255, 0.14);
  --border-color: #d5ddff;
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 19px;
  line-height: 1.55;
  padding: 24px;
  margin: 0;
  background: linear-gradient(145deg, #061b3a, #133b73 55%, #1f5f8f);
  color: var(--text-strong);
}

h1, h2 { color: var(--text-strong); }

.container {
  width: 100%;
  max-width: 760px;
  margin: auto;
  background: var(--surface);
  padding: 32px;
  border-radius: 30px;
  box-shadow: var(--card-shadow);
}


.conversion-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 18px;
  margin-top: 12px;
}

.conversion-type {
  
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.conversion-header .conversion-label {
  margin: 0;
}

.city-picker {
  
  display: flex;
  flex-direction: column;
}


.city-select-block {
  display: flex;
  align-items: stretch;
  position: relative;
}

.city-search-wrapper {
  position: relative;
  flex: 1 1 auto;
}

.city-search-wrapper .city-search-input {
  padding-inline-end: 46px;
}

.city-clear-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 14px;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: rgba(15, 27, 44, 0.08);
  color: #0f1b2c;
  font-size: 1.2rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
}

.city-clear-btn:hover {
  background: rgba(15, 27, 44, 0.18);
  color: #000;
}

.city-select-block .form-control {
  margin-top: 0;
}

.city-search-input:disabled {
  background-color: #f3f4f6;
  opacity: 1;
}

.city-suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 18px 38px rgba(15, 27, 44, 0.2);
  max-height: 320px;
  overflow-y: auto;
  padding: 6px;
  z-index: 600;
}

.city-suggestions[hidden] {
  display: none;
}

.city-suggestion-item {
  display: block;
  width: 100%;
  border: none;
  background: transparent;
  text-align: right;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 1rem;
  color: var(--text-strong);
  cursor: pointer;
}

.city-suggestion-item:hover,
.city-suggestion-item:focus {
  background: var(--surface-soft);
  outline: none;
}

.city-suggestion-empty {
  padding: 12px 14px;
  text-align: center;
  color: #64748b;
  font-size: 0.95rem;
}

.city-zone-badge {
  background: var(--surface-soft);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  padding: 8px 14px;
  font-size: 0.95rem;
  color: var(--accent-dark);
  white-space: nowrap;
}

.city-zone-badge[hidden] {
  display: none;
}


label { display: block; margin-top: 12px; font-weight: 600; }

select, input, button {
  width: 100%;
  padding: clamp(12px, 3vw, 18px);
  margin-top: 6px;
  border-radius: 16px;
  border: 1px solid var(--border-color);
  background: #fdfdfd;
  font-size: 1.2rem;
  min-height: 48px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

select:focus, input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(13, 75, 123, 0.12);
  outline: none;
}

input[type="text"], input[type="number"], textarea, select, .result {
  direction: ltr;
  text-align: left;
}


.btntout {
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 600;
  box-shadow: 0 14px 28px rgba(23, 98, 255, 0.25);
}

.btntout:hover { background: var(--accent-dark); }

button {
  background: var(--success);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 1.15rem;
  font-weight: 600;
  box-shadow: 0 12px 24px rgba(35, 197, 133, 0.25);
}

button:hover { background: #199a64; }

.marker-popover {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  min-width: 190px;
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 0.95rem;
  color: var(--text-strong);
}

.marker-popover-body {
  direction: ltr;
  text-align: left;
}

.marker-popover-title {
  font-weight: 700;
  font-size: 1rem;
  width: 100%;
  text-align: right;
}

.marker-popover-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  width: 100%;
  justify-content: flex-end;
}

.marker-action-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  cursor: pointer;
  background: rgba(23, 98, 255, 0.15);
  color: var(--accent-dark);
}

.marker-action-btn.danger {
  background: rgba(214, 31, 70, 0.2);
  color: #aa1438;
}

.marker-action-btn:hover {
  background: rgba(23, 98, 255, 0.25);
}

.marker-action-btn.danger:hover {
  background: rgba(214, 31, 70, 0.3);
}

.marker-remove-btn {
  padding: 6px 14px;
  border: none;
  border-radius: 999px;
  background: #d61f46;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(214, 31, 70, 0.35);
}

.marker-remove-btn:hover {
  background: #aa1438;
}

.reload-btn {
  margin-top: 14px;
  margin-bottom: 12px;
  width: 50px;
  height: 50px;
  padding: 0;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--text-strong);
  background-color: rgb(53, 174, 166);
  box-shadow: 0 12px 24px rgba(43, 151, 149, 0.895);
}

.reload-btn:hover { background: #17233a; }

.reload-btn span { font-size: 1.4rem; color: #fff; }

.download-btn {
  background: #00a8b5;
  margin-top: 12px;
  box-shadow: 0 14px 28px rgba(0, 168, 181, 0.25);
}

.download-btn:disabled,
.btntout:disabled,
button:disabled {
  background: #c2c8d3;
  box-shadow: none;
  cursor: not-allowed;
}

.result {
  margin-top: 20px;
  padding: 18px;
  background: var(--surface-soft);
  border-left: 5px solid var(--success);
  white-space: pre-wrap;
  direction: ltr;
  text-align: left;
  border-radius: 18px;
}

.hint {
  font-size: 1rem;
  color: #334155;
  margin-top: 6px;
  direction: rtl;
  text-align: right;
}

.csv-image {
  display: none;
  margin-top: 12px;
  max-width: 100%;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(20, 32, 56, 0.08);
}

.manual-box {
  margin-top: 25px;
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

.live-layout {
  margin-top: 25px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.live-layout .manual-box,
.live-layout .map-box {
  margin-top: 0;
}

.map-box {
  margin-top: 32px;
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
  position: relative;
}

.dms-popup {
  direction: ltr;
  text-align: left;
  display: inline-block;
  font-family: "Segoe UI", Tahoma, sans-serif;
  font-size: 0.95rem;
}

.map-stage {
  position: relative;
  margin-top: 16px;
}

.map-wrapper {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 640;
}

.dropdown-menu .saved-points-label {
  font-weight: 600;
  color: #475569;
  cursor: default;
  pointer-events: none;
}

.saved-points-container {
  max-height: 260px;
  overflow-y: auto;
  padding: 4px 0 8px;
}

.saved-points-scroll {
  max-height: 260px;
  overflow-y: auto;
}

.saved-points-list {
  margin: 0;
  padding: 0 6px 0 0;
  list-style: none;
}

.saved-point-item {
  background: var(--surface-soft);
  border-radius: 14px;
  margin: 6px 8px;
  padding: 8px 10px;
  box-shadow: inset 0 0 0 1px rgba(99, 102, 241, 0.08);
}

.saved-point-item.is-active {
  box-shadow: 0 6px 18px rgba(23, 98, 255, 0.18);
  background: #eef3ff;
}

.saved-point-link {
  width: 100%;
  border: none;
  background: transparent;
  text-align: right;
  direction: rtl;
  color: var(--text-strong);
  font-weight: 600;
  padding: 0;
  margin: 0;
  cursor: pointer;
}

.saved-point-name {
  display: block;
  font-size: 1rem;
}

.saved-point-coords {
  display: block;
  direction: ltr;
  font-size: 0.85rem;
  color: #475569;
}

.saved-point-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 8px;
}

.saved-point-action-btn {
  border: none;
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.85rem;
  background: rgba(23, 98, 255, 0.12);
  color: var(--accent-dark);
  cursor: pointer;
}

.saved-point-action-btn.danger {
  background: rgba(214, 31, 70, 0.18);
  color: #b42337;
}

.saved-point-action-btn:hover {
  background: rgba(23, 98, 255, 0.2);
}

.saved-point-action-btn.danger:hover {
  background: rgba(214, 31, 70, 0.26);
}

.saved-points-bulk-btn {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  background: rgba(23, 98, 255, 0.12);
  color: var(--accent-dark);
  cursor: pointer;
}

.saved-points-bulk-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.dropdown-item.is-armed {
  background: var(--accent);
  color: #fff;
}

.dropdown-item.is-armed:hover {
  background: var(--accent-dark);
  color: #fff;
}

.map-dropdown {
  position: absolute;
  top: 20px;
  left: 20px;
  z-index: 600;
}

.map-dropdown .btn {
  min-width: 0;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 16px 32px rgba(15, 27, 44, 0.2);
}

#map {
  width: 100%;
  height: 380px;
  border-radius: 24px;
  margin-top: 0;
  overflow: hidden;
  box-shadow: 0 26px 60px rgba(15, 27, 44, 0.18);
}

.map-fullscreen-btn {
  position: absolute;
  top: 16px;
  right: 16px;
  width: auto;
  min-width: 0;
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(15, 27, 44, 0.85);
  color: #fff;
  font-size: 0.95rem;
  z-index: 640;
}

.map-fullscreen-btn:hover {
  background: rgba(15, 27, 44, 0.92);
}

body.map-fullscreen-active {
  overflow: hidden;
}

body.map-fullscreen-active .map-box {
  position: fixed;
  inset: 0;
  margin: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  z-index: 1200;
}

body.map-fullscreen-active .map-box > h3,
body.map-fullscreen-active .map-box > .hint {
  display: none;
}

body.map-fullscreen-active .map-stage {
  margin-top: 0;
}

body.map-fullscreen-active .map-wrapper {
  position: absolute;
  top: 24px;
  left: 24px;
  z-index: 1210;
}

body.map-fullscreen-active #map {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  margin-top: 0;
  border-radius: 0;
  box-shadow: none;
  z-index: 1205;
}

body.map-fullscreen-active .map-fullscreen-btn {
  top: 24px;
  right: 24px;
  background: rgba(226, 232, 240, 0.9);
  color: #0f172a;
  box-shadow: 0 20px 40px rgba(15, 27, 44, 0.45);
  z-index: 1215;
}

.leaflet-bottom.leaflet-left .leaflet-control-scale {
  margin-bottom: 70px;
}
.gps-btn {
  position: absolute;
  top: 20px;
  left: 20px;
  width: auto;
  min-width: 0;
  padding: 12px 22px;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow: 0 16px 32px rgba(23, 98, 255, 0.28);
  z-index: 500;
}

.select-point-btn {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: auto;
  min-width: 0;
  padding: 12px 20px;
  border-radius: 999px;
  border: 2px dashed var(--accent);
  background: var(--surface);
  color: var(--accent);
  font-size: 0.95rem;
  box-shadow: 0 16px 32px rgba(15, 27, 44, 0.18);
  z-index: 500;
  transition: background 0.2s ease, color 0.2s ease, border-style 0.2s ease;
}

.select-point-btn.is-armed {
  background: var(--accent);
  color: #fff;
  border-style: solid;
}

#map.map-select-armed {
  cursor: crosshair;
}

.gps-btn:hover {
  background: var(--accent-dark);
}

.basemap-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  width: auto;
  min-width: 0;
  padding: 12px 20px;
  background: #0f1b2c;
  color: #fff;
  border-radius: 999px;
  font-size: 1rem;
  line-height: 1.35;
  text-align: center;
  box-shadow: 0 16px 32px rgba(15, 27, 44, 0.28);
  z-index: 500;
}

.basemap-btn:hover {
  background: #1d3354;
}

.manual-title { margin-top: 0; font-size: 1.25rem; }

.manual-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.manual-fields input {
  flex: 1 1 100%;
  min-width: auto;
  font-size: 1.25rem;
  min-height: 56px;
}

.manual-btn { margin-top: 14px; }

.single-result { margin-top: 18px; }

.dms-group { width: 100%; }

.dms-group label { font-size: 0.95rem; margin-bottom: 6px; display: block; }

.dms-row {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  align-items: center;
  direction: ltr;
}

.dms-row input {
  flex: 1 1 auto;
  min-width: 80px;
  font-size: 1.2rem;
  min-height: 52px;
}

.dms-row select {
  width: auto;
  min-width: 110px;
  font-size: 1.2rem;
  min-height: 52px;
}

.hemisphere-select { flex: 1 1 100%; }

#batchSection {
  margin-top: 30px;
  padding: 26px;
  border: 1px solid var(--border-color);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: var(--card-shadow);
}

@media (min-width: 641px) {
  .live-layout {
    flex-direction: row-reverse;
    align-items: stretch;
  }

  .live-layout .manual-box,
  .live-layout .map-box {
    flex: 1 1 0;
  }

  .conversion-header {
    flex-wrap: nowrap;
    align-items: flex-start;
  }

  .conversion-header .conversion-label {
    flex: 0 1 auto;
    white-space: nowrap;
  }

  .city-picker {
    flex: 1 1 420px;
    min-width: 320px;
  }

  .conversion-type {
    flex: 0 0 320px;
  }
}

@media (max-width: 640px) {
  body {
    padding: 0;
    background: linear-gradient(180deg, #04112b, #062046);
    font-size: 24px;
    line-height: 1.85;
  }

  .conversion-header {
    flex-direction: column;
  }

  .container {
    max-width: 100% !important;
    border-radius: 0;
    min-height: 100vh;
    padding: 32px 0 60px;
    margin: 0 ;
    box-shadow: none;
    
  }

  h2 { font-size: 1.75rem; }
  .manual-title { font-size: 1.55rem; }

  .manual-fields {
    flex-direction: column;
    gap: 18px;
  }

  .manual-fields input {
    flex: 1 1 100%;
    min-width: auto;
  }

  .dms-row {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 8px;
  }

  .dms-row input,
  .dms-row select {
    flex: 1 1 0;
    min-width: 0;
    font-size: 1.1rem;
    min-height: 48px;
  }

  button, .btntout, .download-btn {
    font-size: 1.4rem;
    padding: clamp(16px, 5vw, 22px);
    border-radius: 18px;
  }

  .manual-box, #batchSection {
    padding: 22px;
    border-radius: 28px;
  }

  .map-box {
    padding: 20px;
    border-radius: 0;
    margin-top: 34px;
  }

  .gps-btn {
    top: 12px;
    left: 12px;
    font-size: 1.1rem;
    padding: 10px 18px;
  }

  .select-point-btn {
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.05rem;
    padding: 10px 16px;
  }

  .basemap-btn {
    top: 12px;
    right: 12px;
    font-size: 1.05rem;
    padding: 10px 18px;
  }

  #map {
    height: clamp(260px, 48vh, 420px);
    border-radius: 0;
  }

  .result {
    font-size: 1.25rem;
    border-left-width: 0;
    border-radius: 20px;
  }

  select, input {
    border-radius: 18px;
    font-size: 0.8rem;
    min-height: clamp(52px, 12vw, 68px);
  }

  .conversion-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .city-picker {
    flex-direction: column;
    align-items: stretch;
  }

  .city-select-block {
    flex-direction: column;
  }

  .city-search-wrapper {
    width: 100%;
  }

  .city-zone-badge {
    width: 100%;
    text-align: center;
  }

  .hint { font-size: 1.25rem; }
}