html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: 'Cal Sans', sans-serif !important;
}

#top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background-color: #2c3e50;
  color: white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  height: 56px;
  box-sizing: border-box;
  gap: 10px;
  flex-wrap: nowrap;
  border: none;
}

.left-buttons {
  display: flex;
  align-items: center;
  gap: 8px;
}

.text-button {
  background: none;
  border: none;
  padding: 6px 10px;
  margin: 0;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s ease;
  font-family: 'Cal Sans', sans-serif !important;
}

.right-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

#search-container {
  display: flex;
  align-items: center;
  gap: 6px;
  position: relative; 
  width: 100%;
  max-width: 300px;
}

#search-input {
  width: 180px;
  padding: 6px 10px;
  border: 0px solid #ccc;
  border-radius: 1px;
  font-size: 13px;
  background-color: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  transition: border-color 0.3s ease;
}

#search-input:focus {
  border-color: #038a5c;
  outline: none;
}

#clear-search {
  position: absolute;
  right: 10px;
  top: 45%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 18px;
  color: #999;
  user-select: none;
}

#clear-search:hover {
  color: #000;
}

#search-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #ffffff;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  max-height: 280px;
  overflow-y: auto;
  z-index: 1000;
  padding: 0;
  list-style: none;
}

#search-suggestions li.header {
  padding: 8px 14px;
  background-color: #f0f3f6;
  color: #555;
  font-size: 11px;
  font-weight: bold;
  text-transform: uppercase;
  border-bottom: 1px solid #ddd;
  cursor: default;
}

#search-suggestions:empty {
  display: none;
  border: none;
  box-shadow: none;
}

#search-suggestions li {
  padding: 10px 14px;
  font-size: 13px;
  color: #2c3e50;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#search-suggestions li:last-child {
  border-bottom: none;
}

#search-suggestions li:hover {
  background-color: #e1f4ee;
}

.text-button {
  background: none;
  border: none;
  padding: 6px 10px;
  margin: 0;
  color: white;
  font-size: 14px;
  cursor: pointer;
  transition: color 0.2s ease;
}

.text-button:hover {
  color: #038a5c;
}

.center-header {
  flex-grow: 1;
  text-align: center;
  pointer-events: none;
}

#header {
  font-size: 20px;
  margin: 0; /* remove extra margin */
  padding: 0;
  line-height: 1;
}

/* Map */
#map {
  position: fixed;
  top: 56px;
  bottom: 0;
  left: 0;
  right: 0;
  flex: 1;
  z-index: 0;
}

/* Sidebar */
#sidebar {
  position: fixed;
  top: 56px;
  right: 0;
  width: 240px;
  height: calc(100dvh - 56px);
  background: #f5f7fa;
  border-left: 1px solid #ccc;
  padding: 0 16px 16px 16px;
  overflow-y: auto;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s ease-in-out;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  box-shadow: -2px 0 6px rgba(0,0,0,0.1);
}

#sidebar.visible {
  transform: translateX(0);
}

#closeSidebar {
  background: #f5f7fa;
  color: #000;
  border: none;
  padding: 6px 12px;
  margin: 10px;
  font-size: 16px;
  cursor: pointer;
  border-radius: 4px;
  align-self: flex-end;
}

  /* Tab */
  .tab-buttons {
    display: flex;
    margin-bottom: 12px;
    gap: 6px;
  }

  .tab-btn {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ccc;
    background: #fff;
    cursor: pointer;
    font-weight: 500;
    border-radius: 4px;
    transition: background 0.2s ease;
  }

.tab-btn:hover {
  background: #e1f4ee;
}

.tab-btn.active {
  background: #038a5c;
  color: white;
  border-color: #038a5c;
}

.tab-btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  pointer-events: auto; /* still clickable */
}

.tab-pane {
  display: none;
  font-size: 14px;
  line-height: 1.5;
}

.tab-pane.active {
  display: block;
}

.tab-btn.disabled {
  opacity: 0.6;
  cursor: not-allowed;
  text-align: center;
}

.tab-btn.disabled .login-notice {
  font-size: 8px;
  color: #d9534f; /* or gray */
  display: block;
  margin-top: 2px;
}

.btn-group {
  display: flex;
  gap: 6px; /* space between buttons */
}

.btn-link {
  flex: 1; /* equal width */
  text-align: center;
  padding: 6px 8px;
  background-color: #038a5c;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 12px;
  transition: background-color 0.2s;
}

.btn-link:hover {
  background-color: #026141;
}

.nav-button-group {
  display: flex;
  gap: 10px;       /* spacing between buttons */
  margin-top: 10px;
}
  
.nav-button {
  flex: 1;         /* equal width */
  padding: 6px 12px;
  background-color: #038a5c;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  text-align: center;
  transition: background-color 0.2s;
}

.nav-button:hover {
  background-color: #026141;
}

.nav-button.cancel {
  background-color: #ccc;
  color: #333;
}

  /* Context Menu */
  .map-context-menu {
    background: rgba(255,255,255,0.75);
    border: 1px solid #ccc;
    box-shadow: 2px 2px 6px rgba(0,0,0,0.2);
    padding: 5px 0;
    border-radius: 4px;
    font-size: 12px;
    width: 120px;
  }

.map-context-menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.map-context-menu li {
  padding: 2px 8px;
  cursor: pointer;
}

.map-context-menu li:hover {
  background-color: #f0f0f0;
}

.map-context-menu hr {
  margin: 4px 0;
  border: none;
  border-top: 1px solid #ccc;
}

/* Footer label */
#footer-label {
  position: fixed;
  bottom: 10px;
  left: 10px;
  background: rgba(255, 255, 255, 0.75);
  padding: 5px 10px;
  font-size: 12px;
  color: #333;
  border-radius: 4px;
  box-shadow: 0 0 5px rgba(0,0,0,0.2);
  z-index: 1000;
  user-select: none;
}

/* Marker Styles */
/* Base */
.custom-marker {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid #000;
}

/* Highlighted */
.custom-marker.highlighted-marker {
  background-color: yellow;
  border: 2px solid red;
}

.custom-marker.default-marker {
  background-color: #36454F; /* fallback color */
}

/* Substation 1 (Teal shades) */
.custom-marker.marker-S1F1 { background-color: #008080; }
.custom-marker.marker-S1F2 { background-color: #24e3d9; }
.custom-marker.marker-S1F3 { background-color: #009688; }
.custom-marker.marker-S1F4 { background-color: #006666; }

/* Substation 2 (Green shades) */
.custom-marker.marker-S2F1 { background-color: #065c06; }
.custom-marker.marker-S2F2 { background-color: #228B22; }
.custom-marker.marker-S2F3 { background-color: #32CD32; }
.custom-marker.marker-S2F4 { background-color: #90EE90; }

/* Substation 3 (Red shades) */
.custom-marker.marker-S3F1 { background-color: #FF0000; }
.custom-marker.marker-S3F2 { background-color: #B22222; }
.custom-marker.marker-S3F3 { background-color: #FF4500; }
.custom-marker.marker-S3F4 { background-color: #FA8072; }

/* Substation 4 (Purple shades) */
.custom-marker.marker-S4F1 { background-color: #800080; }
.custom-marker.marker-S4F2 { background-color: #8A2BE2; }
.custom-marker.marker-S4F3 { background-color: #9932CC; }
.custom-marker.marker-S4F4 { background-color: #DDA0DD; }

/* Substation 5 (Orange shades) */
.custom-marker.marker-S5F1 { background-color: #FF6A00; }
.custom-marker.marker-S5F2 { background-color: #FFA500; }
.custom-marker.marker-S5F3 { background-color: #FFD700; }
.custom-marker.marker-S5F4 { background-color: #FFE4B5; }

/* Substation 6 (Brown shades) */
.custom-marker.marker-S6F1 { background-color: #8B4513; }
.custom-marker.marker-S6F2 { background-color: #A0522D; }
.custom-marker.marker-S6F3 { background-color: #CD853F; }
.custom-marker.marker-S6F4 { background-color: #DEB887; }

.legend-container {
  font-size: 14px;
  font-family: inherit;
  background: rgba(255,255,255,0.85);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  padding: 6px;
  overflow: hidden;
}

.leaflet-bottom.leaflet-left .legend-container {
  margin-bottom: 10px; /* adjust spacing from bottom */
}

.legend-box {
  width: 165px;
}

.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
  margin-bottom: 4px;
}

.legend-header button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 12px;
}

.legend-items {
  max-height:350px;
  overflow-y: auto;
}

.legend-items div {
  display: flex;
  align-items: center;
  margin: 2px 10px;
}

.legend-items > div:not(.legend-items-title) {
  margin-left: 12px;
}

.legend-color {
  width: 14px;
  height: 14px;
  display: inline-block;
  margin-right: 8px;
  border-radius: 50%;
  border: 0px solid #000;
}

/* Legend overrides */
.legend-extra {
  margin: 5px 0;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 10px;
}

.legend-item .dtrate-badge {
  position: static;      /* reset absolute */
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 12px solid #ff4d00;
}

.legend-item .dtrate-badge::before {
  content: none; /* hide the white border layer for legend */
}

.legend-item .account-badge {
  position: static;
  background: blue;
  color: white;
  border-radius: 25%;
  width: 12px;          /* fixed smaller width */
  height: 14px;         /* fixed smaller height */
  font-size: 10px;       /* smaller text */
  font-weight: bold;
  border: 0.5px solid #000;
  display: flex;        /* flexbox centers the text */
  align-items: center;
  justify-content: center;
  text-shadow: none;
}

#showLegend {
  display: block;
  padding: 4px 6px;
  background: rgba(255, 255, 255, 0.0);
  border: 0px solid #ccc;
  font-family: inherit;
  overflow: hidden;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
}

#showLegend.hidden {
  display: none;
}

.substation-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  background-color: #f9d71c; /* bright yellow */
  border: 2px solid #fff;
  border-radius: 6px; /* square with soft corners */
  font-size: 16px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 3px #000;
  box-shadow: 0 0 6px rgba(0,0,0,0.5);
}

.substation-marker {
  background: transparent !important;
  border: none !important;
}


.pole-label {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 9px;
  font-weight: bold;
  text-shadow: 0 0 4px #000;
  transform: translateY(2px);
}

.account-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  background: blue;
  color: white;
  border-radius: 25%;
  padding: 0.5px 3px;
  font-size: 8px;
  text-shadow: 0 0 2px #000;
  border: 0.2px solid #000;
}

.dtrate-badge {
  position: absolute;
  top: -16px;
  left: -20px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 14px solid transparent;
  border-top: 21px solid #ff4d00;   /* triangle fill */
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Border effect */
.dtrate-badge::before {
  content: "";
  position: absolute;
  top: -22px;
  left: -14px;
  width: 0;
  height: 0;
  border-left: 14px solid transparent;
  border-right: 15px solid transparent;
  border-top: 23px solid white;    /* border color */
  z-index: -1;
}

/* Text inside triangle */
.dtrate-badge span {
  position: relative;
  top: -14px; /* slight nudge downward */
  font-size: 9px;
  font-weight: bold;
  color: white;
  text-shadow: 0 0 2px #000;
  line-height: 1;
}

/* Account list */
.account-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.account-item {
  background: #ffffff;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: background 0.3s ease;
}

.account-item:hover {
  background: #f0f9f5;
}

.account-name {
  font-weight: 600;
  cursor: pointer;
  color: #2c3e50;
  display: flex;
  align-items: center;
}

.acc-toggle-icon {
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.2s ease;
}

.account-details {
  margin-top: 8px;
  padding-left: 18px;
  font-size: 13px;
  background: #f9f9f9;
  border-left: 3px solid #2c3e50;
  border-radius: 3px;
  display: none;
  color: #333;
}

.account-details.visible {
  display: block;
}

.account-name.open .acc-toggle-icon {
  transform: rotate(90deg);
}

/* Pole list */
.pole-list {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

.pole-item {
  background: #ffffff;
  padding: 10px 12px;
  border: 1px solid #ccc;
  border-radius: 6px;
  margin-bottom: 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
  transition: background 0.3s ease;
}

.pole-item:hover {
  background: #eef9f3;
}

.pole-name {
  font-weight: 600;
  cursor: pointer;
  color: #1e2b36;
  display: flex;
  align-items: center;
}

.pole-toggle-icon {
  display: inline-block;
  margin-right: 6px;
  transition: transform 0.2s ease;
}

.pole-details {
  margin-top: 8px;
  padding-left: 18px;
  font-size: 13px;
  background: #f9f9f9;
  border-left: 3px solid #1e2b36;
  border-radius: 3px;
  display: none;
  color: #333;
}

.pole-details.visible {
  display: block;
}

.pole-name.open .pole-toggle-icon {
  transform: rotate(90deg);
}

/* Line toggle */
.line-toggle-card {
  position: absolute;
  top: 68px;
  left: 10px;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.85);
  padding: 4px 6px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  font-size: 12px;
  width: 140px;
}

.line-toggle-card .toggle-title {
  font-weight: bold;
  font-size: 12px;
  margin-bottom: 6px;
  color: #333;
  border-bottom: 1px solid #ccc;
  padding-bottom: 4px;
}

.toggle-option {
  display: flex;
  align-items: center;
  margin-bottom: 4px;
  color: #222;
}

.toggle-option input[type="checkbox"] {
  margin-right: 6px;
  width: 16px;
  height: 16px;
  accent-color: #04b553;
}

  .leaflet-tooltip.measure-label {
    background: rgba(0, 0, 0, 0.75);
    color: #fff;
    font-size: 12px;
    font-weight: bold;
    border: none;
    border-radius: 4px;
    padding: 3px 6px;
    text-align: center;
    white-space: nowrap;
  }

  .leaflet-control-zoom {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    border-radius: 6px;
    overflow: hidden;
  }

  .leaflet-control-zoom a {
    background-color: white;
    color: black;
    font-size: 18px;
  }

  .leaflet-bottom.leaflet-left {
    bottom: 40px;
  }

  .leaflet-bottom.leaflet-right .leaflet-control.locate-btn {
    margin-bottom: 20px;
    margin-right: 10px;
  }
  
  .leaflet-overlay-pane,
.leaflet-marker-pane,
.leaflet-shadow-pane,
.leaflet-popup-pane {
  filter: none !important;
}

  
.floating-modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(255, 255, 255, 0.97);
  padding: 0;
  border-radius: 12px;
  box-shadow: 0 0 10px #000;
  max-height: 80vh;
  max-width: 95vw;
  overflow: auto;
  resize: both;
  cursor: move;
}

.floating-modal-header {
  background: #007b5e;
  color: white;
  padding: 10px;
  font-weight: bold;
  cursor: move;
  position: sticky;
  top: 0;
  z-index: 1;
  border-top-left-radius: 12px;
  border-top-right-radius: 12px;
}

.floating-modal-content {
  padding: 15px;
}

#downstreamExportTable {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

#downstreamExportTable th,
#downstreamExportTable td {
  border: 1px solid #ccc;
  padding: 6px;
  text-align: center;
}

#downstreamExportTable th {
  background-color: #f0f0f0;
}

.close-btn {
  position: absolute;
  top: 5px;
  right: 12px;
  font-size: 20px;
  cursor: pointer;
}

.downstream-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 15px;
}

.downstream-table th, .downstream-table td {
  padding: 8px 10px;
  border: 1px solid #ddd;
  text-align: center;
}

.downstream-table th {
  background-color: #f2f2f2;
}

.modal-title {
  position: sticky;
  top: 0;
  background: #fff;
  padding: 10px;
  font-size: 18px;
  font-weight: bold;
  z-index: 10;
  border-bottom: 1px solid #ccc;
}

.export-btn {
  background-color: #ffc107;
  color: #000;
  padding: 6px 12px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.export-btn:hover {
  background-color: #e0a800;
}

.floating-modal-footer {
  background: #fff;
  padding: 10px 15px;
  border-top: 1px solid #ccc;
  position: sticky;
  bottom: 0;
  z-index: 2;
  text-align: right;
}

#confirm-modal .nav-button {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 6px;
  cursor: pointer;
}

#confirm-modal .nav-button:hover {
  background-color: #026141;
  color: white;
}

.edit-mode-on {
  background-color: #007b5e;
  color: white;
}

#highlightOverlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  background-color: rgba(0, 0, 0, 0.6);
  clip-path: circle(0px at 0 0);
  transition: clip-path 0.5s ease-out;
  z-index: 9999;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

#toast {
  visibility: hidden;
  min-width: 250px;
  background-color: #fff;
  color: #333;
  text-align: center;
  border-radius: 8px;
  padding: 12px 18px;
  position: fixed;
  z-index: 9999;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.4s, bottom 0.4s;
  box-shadow: 0 0 4px #000;
}

#toast.show {
  visibility: visible;
  opacity: 1;
  bottom: 50px;
}

.map-options {
  position: absolute;
  top: 65px;
  left: 10px;
  z-index: 9999;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  font-family: inherit;
  width: 160px;
  overflow: hidden;
  font-size: 14px;
  text-align: left;
}

.dropdown-toggle {
  background: rgba(255, 255, 255, 0.85);
  padding: 5px;
  text-align: center;
  cursor: pointer;
  border-bottom: 1px solid #ddd;
}

.map-options-content {
  padding: 10px;
}

.hidden {
  display: none;
}

.switch {
  display: flex;
  align-items: center;
  margin-bottom: 10px;
  justify-content: space-between;
  gap: 8px;
  font-size: 14px;
}

.switch input {
  display: none;
}

.slider {
  position: relative;
  width: 40px;
  height: 20px;
  background-color: #e0e0e0;
  border-radius: 20px;
  transition: background-color 0.3s;
  cursor: pointer;
  box-shadow: inset 2px 2px 4px #c1c1c1, inset -2px -2px 4px #ffffff;
}

.slider::before {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  top: 1px;
  left: 1px;
  background-color: #fdfdfd;
  border-radius: 50%;
  transition: transform 0.3s;
  box-shadow: 1px 1px 2px #aaa, -1px -1px 2px #fff;
}

input:checked + .slider {
  background-color: #038a5c; /* your vivid green */
  box-shadow: inset 2px 2px 4px #026141, inset -2px -2px 4px #04b573;
}

input:checked + .slider::before {
  transform: translateX(20px);
}

.switch-label {
  flex: 1;
}

/* Mobile View */
@media (max-width: 768px) {
  #top-bar {
    flex-direction: column;
    align-items: center;
    height: auto;
    padding: 10px;
    gap: 10px;
  }

  .left-buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 10px;
    width: 100%;
  }

  .right-search {
    display: flex;
	flex-direction: row;
    justify-content: center;
    width: 100%;
  }

  #search-container {
    display: flex;
    flex-direction: row;
    align-items: center;
    width: 100%;
    gap: 8px;
    justify-content: center;
  }

  #search-input {
    flex: 1;
    min-width: 0;
  }

  .text-button {
    white-space: nowrap;
  }

  .center-header {
    display: none !important;
  }

  #sidebar {
    top: 88px;
  }

  .line-toggle-card {
    top: 100px;
  }
  
  #map {
  top: 88px;
  }
  
  .map-options {
  top: 92px;
  z-index: 9998;
  }
}