:root {
  --bg: #ffffff;
  --panel: #f3f3f3;
  --text: #151515;
  --muted: #4f4f4f;
  --stroke: #d1d1d1;
  --accent: #DC241f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: #ffffff;
  color: var(--text);
  font-family: "Lato", "Segoe UI", sans-serif;
}

.app {
  position: relative;
  max-width: 1200px;
  margin: 16px auto;
  background: var(--bg);
  border: 0;
  box-shadow: none;
  padding: 22px 20px 14px;
}

.app:fullscreen {
  max-width: none;
  width: 100vw;
  height: 100vh;
  margin: 0;
  padding: 18px 18px 10px;
  background: #ffffff;
  overflow: auto;
}

.header {
  text-align: center;
  margin-bottom: 8px;
  padding-right: 220px;
}

.header h1 {
  font-family: "Lato", "Segoe UI", sans-serif;
  font-weight: 900;
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.02em;
}

.header p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.35rem);
}

.brand-logos {
  position: absolute;
  top: 18px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 2;
}

.brand-logo {
  display: block;
  width: auto;
  height: 36px;
}

.labourlist-logo {
  height: 34px;
}

.plmr-logo {
  height: 30px;
}

.legend-wrap {
  min-height: 30px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 8px 0 6px;
}

.legend-title {
  font-weight: 700;
  color: #2b2b2b;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #333;
  font-size: 0.95rem;
}

.swatch {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.2);
}

.chart-wrap {
  position: static;
}

.app:fullscreen #chart {
  height: max(720px, calc(100vh - 28px));
}

.app:fullscreen .controls {
  top: 18px;
  left: 18px;
}

.app:fullscreen .map-controls {
  top: 18px;
  left: 18px;
}

.app:fullscreen .data-status {
  position: absolute;
}

#chart {
  width: 100%;
  height: clamp(560px, 72vh, 900px);
  display: block;
}

.data-status {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 16px;
  background: rgba(255, 255, 255, 0.78);
  color: #313131;
  font-weight: 700;
  z-index: 6;
}

.data-status.visible {
  display: flex;
}

.data-status.error {
  color: #8c1d1d;
}

.map-controls {
  position: absolute;
  left: 14px;
  top: 14px;
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 7;
}

.map-controls.visible {
  display: flex;
}

.map-controls button {
  width: 34px;
  height: 34px;
  border: 1px solid #c8c8c8;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #252525;
  font: inherit;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

#fullscreenToggle {
  font-size: 1rem;
}

.controls {
  position: absolute;
  left: 10px;
  right: auto;
  top: 12px;
  background: rgba(246, 246, 246, 0.95);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  width: 220px;
  padding: 10px;
  backdrop-filter: blur(4px);
  z-index: 8;
}

.controls-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: grab;
  user-select: none;
}

.controls-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.controls h2 {
  margin: 0;
  font-family: "Lato", "Segoe UI", sans-serif;
  font-size: 1rem;
  font-weight: 900;
}

.toggle-display {
  width: 30px;
  height: 30px;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  background: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.controls-body {
  margin-top: 8px;
}

.controls.collapsed .controls-body {
  display: none;
}

.controls.collapsed {
  width: 126px;
  padding: 6px 8px;
  border-radius: 999px;
  background: rgba(246, 246, 246, 0.96);
  cursor: pointer;
}

.controls.collapsed .controls-header h2 {
  font-size: 0.92rem;
}

.controls.collapsed .controls-header {
  cursor: pointer;
}

.controls.collapsed .toggle-display {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  font-size: 0.95rem;
  line-height: 1;
}

.controls.collapsed .controls-actions {
  gap: 4px;
}

.controls label {
  display: block;
  margin: 10px 0 4px;
  font-weight: 700;
  font-size: 0.95rem;
}

.controls select {
  width: 100%;
  border: 1px solid #c8c8c8;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
}

.controls input[type="search"] {
  width: 100%;
  border: 1px solid #c8c8c8;
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
}

.search-row {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 6px;
}

.search-arrow {
  border: 1px solid #c8c8c8;
  border-radius: 8px;
  background: #fff;
  color: #2f2f2f;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.search-arrow:disabled {
  color: #9a9a9a;
  cursor: not-allowed;
}

.footer {
  color: #3f3f3f;
  font-size: 1.7rem;
  margin-top: 8px;
}

.group-label {
  font-size: 14px;
  font-weight: 700;
  fill: #2f2f2f;
}

.panel-label {
  font-size: 18px;
  font-weight: 700;
  fill: #2f2f2f;
  font-family: "Lato", "Segoe UI", sans-serif;
}

.dot {
  stroke: #fff;
  stroke-width: 1;
  transition: stroke-width 140ms ease, filter 140ms ease;
  cursor: pointer;
}

.dot.dot-highlighted {
  stroke: #111;
  stroke-width: 2.2;
  filter: drop-shadow(0 0 2px rgba(17, 17, 17, 0.28));
}

.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  opacity: 0;
  transform: translate(10px, 10px);
  background: rgba(23, 23, 23, 0.94);
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.9rem;
  line-height: 1.3;
  white-space: nowrap;
  transition: opacity 120ms ease;
}

.tooltip.visible {
  opacity: 1;
}

.mp-card-overlay {
  position: fixed;
  inset: 0;
  background: rgba(14, 14, 14, 0.3);
  z-index: 30;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.mp-card-overlay.visible {
  display: flex;
}

.mp-card {
  width: min(760px, 100%);
  max-height: min(86vh, 900px);
  overflow: auto;
  background: #f7f7f7;
  border: 1px solid #d3d3d3;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.22);
  padding: 18px 20px 16px;
  position: relative;
}

.mp-card-close {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 1px solid #cfcfcf;
  border-radius: 8px;
  background: #fff;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}

.mp-card h3 {
  margin: 0;
  font-family: "Lato", "Segoe UI", sans-serif;
  font-size: 1.4rem;
  padding-right: 96px;
}

.mp-card-sub {
  margin: 6px 0 10px;
  color: #4a4a4a;
}

.mp-card-photo-wrap {
  position: absolute;
  top: 16px;
  right: 52px;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid #e0e0e0;
  background: #ececec;
}

.mp-card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.mp-card-similarity {
  margin: 8px 0 12px;
  font-size: 0.95rem;
}

.mp-card-similarity button {
  margin-right: 6px;
  margin-top: 6px;
  border: 1px solid #c9c9c9;
  border-radius: 999px;
  padding: 4px 10px;
  background: #fff;
  cursor: pointer;
  font: inherit;
}

.mp-card-fields {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.mp-card-field {
  border: 1px solid #dedede;
  background: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}

.mp-card-field strong {
  display: block;
  font-size: 0.88rem;
  color: #525252;
  margin-bottom: 2px;
}

@media (max-width: 980px) {
  #chart {
    height: 680px;
  }

  .legend-item {
    font-size: 0.88rem;
  }

  .controls {
    width: min(250px, calc(100% - 20px));
    left: 10px;
    right: auto;
    top: 10px;
  }

  .header {
    padding-right: 0;
    padding-top: 52px;
  }

  .brand-logos {
    top: 12px;
    right: 12px;
  }

  .brand-logo {
    height: 28px;
  }

  .labourlist-logo {
    height: 27px;
  }

  .plmr-logo {
    height: 24px;
  }
}

@media (max-width: 620px) {
  .app {
    padding: 14px 12px 12px;
  }

  #chart {
    height: 760px;
  }

  .header h1 {
    font-size: clamp(1.6rem, 8vw, 2.3rem);
  }

  .header p {
    font-size: clamp(0.92rem, 4vw, 1.1rem);
  }

  .controls {
    padding: 10px;
    width: min(210px, calc(100% - 16px));
    left: 8px;
    right: auto;
    top: 8px;
  }

  .footer {
    font-size: 1rem;
  }
}
