html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.topbar {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  background: #fff;
  position: relative;
  z-index: 1100;
}

.topbar .left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar .right {
  display: flex;
  align-items: center;
  gap: 10px;
}


.top-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}

.link-icon {
  font-size: 15px;
}

.link-text {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.2;
}

.icon-btn {
  appearance: none;
  border: 1px solid rgba(0,0,0,0.14);
  background: #fff;
  color: #111;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
}

.icon-btn-toggle {
  padding: 6px 10px;
  text-align: center;
  font-size: 14px;
  white-space: nowrap;
}

.icon-btn-toggle.off {
  opacity: 0.55;
}

.icon-btn:hover {
  background: rgba(0,0,0,0.04);
}

.title {
  font-weight: 600;
}

.status {
  font-size: 13px;
  opacity: 0.9;
  white-space: nowrap;
}

.sep {
  margin: 0 8px;
  opacity: 0.4;
}

#map {
  height: calc(100% - 48px);
  width: 100%;
}

/* ---- Sidebar ---- */
.sidebar {
  position: absolute;
  top: 48px;
  left: 0;
  height: calc(100% - 48px);
  width: 440px;
  min-width: 320px;
  max-width: 90vw;
  background: #fff;
  border-right: 1px solid rgba(0,0,0,0.12);
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  transform: translateX(-102%);
  transition: transform 180ms ease;
  z-index: 1050;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-backdrop {
  position: absolute;
  top: 48px;
  left: 0;
  width: 100%;
  height: calc(100% - 48px);
  background: rgba(0,0,0,0.22);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
  z-index: 1040;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 8px 10px;
  border-bottom: 1px solid rgba(0,0,0,0.10);
}

.sidebar-title {
  font-weight: 650;
}

.sidebar-controls {
  padding: 10px;
  border-bottom: 1px solid rgba(0,0,0,0.10);
}

.columns {
  margin-top: 10px;
}

.columns > summary {
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

.col-toggles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 6px 10px;
  margin-top: 8px;
}

.col-toggles label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  white-space: normal;
  word-break: break-word;
}

.sidebar-list {
  flex: 1;
  overflow: auto;
}

.nodes-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.nodes-table thead th {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 2;
  border-bottom: 1px solid rgba(0,0,0,0.10);
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: -6px; /* sit on the border, avoid blocking clicks inside */
  height: 100%;
  width: 12px;
  cursor: col-resize;
  user-select: none;
  touch-action: none;
  background: linear-gradient(to right, rgba(0,0,0,0.0), rgba(0,0,0,0.06));
}

.sidebar-resize-handle:hover {
  background: linear-gradient(to right, rgba(0,0,0,0.0), rgba(0,0,0,0.12));
}

.nodes-table tbody td {
  border-bottom: 1px solid rgba(0,0,0,0.06);
  padding: 7px 10px;
  white-space: nowrap;
}

.nodes-table tbody tr:hover {
  background: rgba(0,0,0,0.03);
}

.nodes-table tbody tr.stale td {
  opacity: 0.65;
}

.nodes-table tbody tr.no-coords td {
  opacity: 0.85;
}

.nodes-table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.popup h3 {
  margin: 0 0 6px 0;
  font-size: 14px;
}

.popup table {
  border-collapse: collapse;
  font-size: 13px;
}

.popup td {
  padding: 2px 6px 2px 0;
  vertical-align: top;
}

.popup td.k {
  opacity: 0.7;
  white-space: nowrap;
}

.badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 12px;
  background: rgba(0,0,0,0.06);
  margin-left: 6px;
}

.node-marker {
  width: 14px;
  height: 14px;
  position: relative;
  overflow: visible;
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,0.35);
  box-sizing: border-box;
  background: #2a7fff; /* active default */
  box-shadow: 0 1px 6px rgba(0,0,0,0.25);
}

.node-marker.stale {
  background: #8c8c8c;
}

.node-marker:hover {
  transform: scale(1.05);
}

/* allow direction arrow to extend outside the base icon */
.leaflet-marker-icon {
  overflow: visible !important;
}

/* antenna direction arrow (bearing degrees, 0 = north, clockwise) */
.node-marker .dir {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 2px;
  height: 14px;
  background: rgba(0,0,0,0.45);
  transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(var(--dir, 0deg));
  border-radius: 2px;
  pointer-events: none;
}

.node-marker .dir::after {
  content: "";
  position: absolute;
  left: 50%;
  top: -5px;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 6px solid rgba(0,0,0,0.45);
}


@media (max-width: 900px) {
  .link-text {
    display: none;
  }

  .link-btn {
    padding: 6px 8px;
  }

  .status {
    font-size: 12px;
  }
}
