* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #0b0e13;
  color: #e5e7eb;
}

#map {
  position: absolute;
  inset: 0;
}

/* ---------- Top bar ---------- */

#topbar {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 14px;
  background: rgba(13, 17, 26, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  font-size: 13px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.02em;
}

.status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #9ca3af;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}
.dot-off { background: #6b7280; }
.dot-on { background: #4ade80; box-shadow: 0 0 6px #4ade80; }
.dot-wait { background: #facc15; box-shadow: 0 0 6px #facc15; }
.dot-err { background: #f87171; box-shadow: 0 0 6px #f87171; }

.stats {
  color: #9ca3af;
  display: flex;
  gap: 8px;
}
.sep { opacity: 0.4; }

.actions {
  margin-left: auto;
  display: flex;
  gap: 8px;
  align-items: center;
}

.btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 12.5px;
  cursor: pointer;
  transition: background 0.15s;
}
.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn.active {
  background: #2563eb;
  border-color: #3b82f6;
}

.view-toggle {
  display: flex;
}
.view-toggle .btn {
  border-radius: 0;
}
.view-toggle .btn:first-child {
  border-radius: 7px 0 0 7px;
  border-right: none;
}
.view-toggle .btn:last-child {
  border-radius: 0 7px 7px 0;
}

.filter-count {
  display: inline-block;
  min-width: 16px;
  padding: 0 4px;
  margin-left: 4px;
  border-radius: 8px;
  background: #2563eb;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
}
.filter-count.hidden { display: none; }

/* ---------- Filter panel ---------- */

#filter-panel {
  position: absolute;
  top: 62px;
  right: 10px;
  z-index: 11;
  width: 265px;
  max-height: calc(100% - 110px);
  overflow-y: auto;
  background: rgba(13, 17, 26, 0.92);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 12.5px;
}
#filter-panel.hidden { display: none; }

.filter-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 10px;
}
.filter-head a {
  font-weight: 400;
  font-size: 11.5px;
  color: #60a5fa;
  text-decoration: none;
}
.filter-head a:hover { text-decoration: underline; }

.filter-group { margin-bottom: 14px; }

.filter-label {
  color: #d1d5db;
  font-weight: 600;
  font-size: 12px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.filter-value {
  font-weight: 400;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
}

.filter-select {
  width: 100%;
  padding: 5px 8px;
  background: #0b0e13;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 7px;
  color: #e5e7eb;
  font-size: 12.5px;
}
.filter-select:focus { outline: none; border-color: #3b82f6; }

.filter-note {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.45;
  color: #6b7280;
}

.society-items { display: flex; flex-direction: column; }

/* ---------- Dual-ended range slider ---------- */

.dual-slider {
  position: relative;
  height: 24px;
}
.slider-track {
  position: absolute;
  top: 10px;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.14);
}
.slider-range {
  position: absolute;
  top: 10px;
  height: 4px;
  border-radius: 2px;
  background: #3b82f6;
}
.dual-slider input[type="range"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 24px;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  pointer-events: none; /* only the thumbs are interactive */
}
.dual-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  pointer-events: auto;
  width: 14px;
  height: 14px;
  margin-top: 5px;
  border-radius: 50%;
  background: #e5e7eb;
  border: 2px solid #3b82f6;
  cursor: pointer;
}
.dual-slider input[type="range"]::-moz-range-thumb {
  pointer-events: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #e5e7eb;
  border: 2px solid #3b82f6;
  cursor: pointer;
}
.dual-slider input[type="range"]::-moz-range-track { background: none; }

/* ---------- Legend ---------- */

#legend {
  position: absolute;
  bottom: 28px;
  left: 10px;
  z-index: 10;
  background: rgba(13, 17, 26, 0.88);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 12px;
  max-width: 200px;
}
#legend.hidden { display: none; }

.legend-title {
  font-weight: 600;
  margin-bottom: 6px;
  color: #d1d5db;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.legend-links {
  font-weight: 400;
  font-size: 11px;
}
.legend-links a {
  color: #60a5fa;
  text-decoration: none;
}
.legend-links a:hover { text-decoration: underline; }

.legend-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 2px 4px;
  border-radius: 5px;
  cursor: pointer;
  user-select: none;
  color: #d1d5db;
}
.legend-item:hover { background: rgba(255, 255, 255, 0.07); }
.legend-item.off { opacity: 0.4; }

.legend-item input[type="checkbox"] {
  accent-color: #3b82f6;
  width: 13px;
  height: 13px;
  margin: 0;
  cursor: pointer;
}

.legend-label { flex: 1; }

.legend-count {
  color: #6b7280;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ---------- List view ---------- */

#list-view {
  position: absolute;
  top: 62px;
  left: 10px;
  right: 10px;
  bottom: 34px;
  z-index: 9;
  display: flex;
  flex-direction: column;
  background: rgba(13, 17, 26, 0.96);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  overflow: hidden;
}
#list-view.hidden { display: none; }

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-wrap: wrap;
}
.list-count {
  color: #9ca3af;
  font-size: 12.5px;
}
.rank-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: #d1d5db;
}
.rank-label .filter-select { width: auto; }

.list-scroll {
  overflow-y: auto;
  flex: 1;
}

#list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
#list-table th {
  position: sticky;
  top: 0;
  background: #131824;
  color: #9ca3af;
  font-weight: 600;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}
#list-table td {
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  white-space: nowrap;
}
#list-table th.num, #list-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
#list-table tbody tr { cursor: pointer; }
#list-table tbody tr:hover { background: rgba(255, 255, 255, 0.05); }
#list-table a.dest-link, .popup-grid a.dest-link {
  color: #60a5fa;
  text-decoration: none;
}
#list-table a.dest-link:hover, .popup-grid a.dest-link:hover {
  text-decoration: underline;
}
#list-table .swatch {
  display: inline-block;
  margin-right: 7px;
  vertical-align: baseline;
}

/* ---------- Powered by ---------- */

#powered-by {
  position: absolute;
  bottom: 8px;
  right: 10px;
  z-index: 12;
  padding: 4px 10px;
  background: rgba(13, 17, 26, 0.85);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  font-size: 11.5px;
  color: #9ca3af;
  text-decoration: none;
}
#powered-by strong { color: #e5e7eb; font-weight: 600; }
#powered-by:hover { color: #e5e7eb; }

/* ---------- Vessel popup ---------- */

.maplibregl-popup-content {
  background: #131824 !important;
  color: #e5e7eb !important;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px !important;
  padding: 12px 14px !important;
  font-family: inherit !important;
  min-width: 230px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.5) !important;
}
.maplibregl-popup-tip {
  border-top-color: #131824 !important;
  border-bottom-color: #131824 !important;
}
.maplibregl-popup-close-button {
  color: #9ca3af !important;
  font-size: 18px !important;
  right: 6px !important;
  top: 4px !important;
}

.popup-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
  padding-right: 16px;
}
.popup-type {
  font-size: 11.5px;
  font-weight: 600;
  margin-bottom: 8px;
}
.popup-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 3px 12px;
  font-size: 12px;
}
.popup-grid dt { color: #6b7280; }
.popup-grid dd { margin: 0; text-align: right; }
.popup-updated {
  margin-top: 8px;
  font-size: 11px;
  color: #6b7280;
}

.maplibregl-ctrl-attrib {
  background: rgba(13, 17, 26, 0.7) !important;
  font-size: 10.5px;
}
.maplibregl-ctrl-attrib a { color: #9ca3af !important; }
