html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: Arial, Helvetica, sans-serif;
  overflow: hidden;
}

#map {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
}

.panel {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 1000;
  width: 310px;
  box-sizing: border-box;
  padding: 12px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #d8dde3;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(40, 45, 55, 0.16);
  color: #17202a;
}

.timeseries-panel {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  z-index: 1000;
  width: min(980px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 120px));
  box-sizing: border-box;
  padding: 14px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #d8dde3;
  border-radius: 8px;
  box-shadow: 0 8px 22px rgba(40, 45, 55, 0.16);
  color: #17202a;
  overflow: auto;
}

.timeseries-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}

.kicker {
  color: #52606d;
  font-size: 11px;
  text-transform: uppercase;
}

.timeseries-title {
  margin-top: 2px;
  font-size: 16px;
  font-weight: 700;
  word-break: break-all;
}

.icon-button {
  width: 28px;
  height: 28px;
  border: 1px solid #b8c2cc;
  border-radius: 6px;
  background: #fff;
  color: #17202a;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}

.icon-button:hover {
  background: #f3f6f8;
}

.timeseries-status,
.timeseries-hover,
.timeseries-summary {
  min-height: 18px;
  color: #52606d;
  font-size: 13px;
}

.timeseries-status {
  margin-top: 8px;
}

.timeseries-hover {
  margin-top: 8px;
  color: #17202a;
}

.timeseries-hover:empty {
  display: none;
}

.timeseries-chart {
  display: block;
  width: max(100%, 920px);
  height: 340px;
  margin-top: 12px;
  overflow: visible;
}

.chart-grid {
  stroke: #e0e6ed;
  stroke-width: 1;
}

.chart-axis {
  stroke: #9aa5b1;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: #1f6feb;
  stroke-width: 2.5;
}

.chart-point {
  fill: #1f6feb;
  opacity: 0.72;
  pointer-events: none;
}

.chart-point-empty {
  fill: #f97316;
}

.chart-hit-target {
  fill: transparent;
  stroke: transparent;
  cursor: pointer;
  pointer-events: all;
}

.chart-hit-target:hover + .chart-point,
.chart-hit-target:focus + .chart-point {
  opacity: 1;
}

.chart-label {
  fill: #52606d;
  font-size: 12px;
}

.title-row {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.title {
  font-size: 15px;
  font-weight: 700;
}

.info-button {
  position: relative;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  border: 1px solid #7b8794;
  border-radius: 50%;
  background: #fff;
  color: #52606d;
  cursor: help;
  font-size: 13px;
  font-weight: 700;
  line-height: 18px;
  padding: 0;
  text-align: center;
}

.info-button:hover,
.info-button:focus-visible {
  border-color: #1f6feb;
  color: #1f6feb;
}

.info-tooltip {
  position: absolute;
  top: 26px;
  right: 0;
  z-index: 1100;
  display: none;
  width: 276px;
  box-sizing: border-box;
  padding: 10px;
  border: 1px solid #b8c2cc;
  border-radius: 6px;
  background: #fff;
  box-shadow: 0 8px 22px rgba(40, 45, 55, 0.18);
  color: #17202a;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.35;
  text-align: left;
}

.info-button:hover .info-tooltip,
.info-button:focus-visible .info-tooltip,
.info-button:focus-within .info-tooltip {
  display: block;
}

.info-tooltip a {
  color: #1f6feb;
  font-weight: 700;
}

label {
  display: block;
  font-size: 12px;
  color: #52606d;
  margin-bottom: 4px;
}

.panel label:not(:first-of-type) {
  margin-top: 10px;
}

select {
  width: 100%;
  height: 34px;
  border: 1px solid #b8c2cc;
  border-radius: 6px;
  background: #fff;
  color: #17202a;
  font-size: 14px;
  padding: 0 8px;
}

.date-input {
  width: 100%;
  height: 34px;
  box-sizing: border-box;
  border: 1px solid #b8c2cc;
  border-radius: 6px;
  background: #fff;
  color: #17202a;
  font-size: 13px;
  padding: 0 8px;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  width: 100%;
  height: 34px;
  padding: 2px;
  box-sizing: border-box;
  border: 1px solid #b8c2cc;
  border-radius: 6px;
  background: #eef2f5;
}

.panel .segmented-control label {
  display: block;
  margin: 0;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 28px;
  border-radius: 4px;
  color: #52606d;
  cursor: pointer;
  font-size: 12px;
}

.segmented-control input:checked + span {
  background: #fff;
  color: #17202a;
  box-shadow: 0 1px 3px rgba(40, 45, 55, 0.16);
}

.segmented-control input:focus-visible + span {
  outline: 2px solid #1f6feb;
  outline-offset: -2px;
}

.date-range {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.panel .date-range label {
  margin: 0;
}

.date-range span {
  display: block;
  margin-bottom: 4px;
  color: #52606d;
  font-size: 11px;
}

#status {
  min-height: 18px;
  margin-top: 10px;
  color: #52606d;
  font-size: 12px;
}

.legend {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  color: #52606d;
  font-size: 12px;
}

.ramp {
  height: 10px;
  border-radius: 5px;
  background: linear-gradient(90deg, #00ff00, #ffff00, #ff0000);
  border: 1px solid rgba(0, 0, 0, 0.12);
}

.nodata-legend {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  color: #52606d;
  font-size: 12px;
}

.nodata-swatch {
  width: 18px;
  height: 10px;
  box-sizing: border-box;
  border: 1px dashed #7b8794;
  background: transparent;
}

.ownership-banner {
  margin-top: 10px;
  padding: 7px 8px;
  border: 1px solid #d8dde3;
  border-radius: 6px;
  background: rgba(248, 250, 252, 0.92);
  color: #52606d;
  font-size: 11px;
  line-height: 1.3;
}

.ownership-banner a {
  color: #1f5f99;
  text-decoration: underline;
}

.ownership-banner a:hover {
  color: #16476f;
}

.leaflet-container {
  background: #e8eef3;
}

@media (max-width: 700px) {
  .panel {
    top: 10px;
    right: 10px;
    left: 10px;
    width: auto;
    max-height: min(62vh, 520px);
    padding: 10px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .title-row {
    align-items: start;
    margin-bottom: 8px;
  }

  .title {
    font-size: 14px;
    line-height: 1.25;
  }

  .info-button {
    width: 24px;
    height: 24px;
    line-height: 22px;
  }

  .info-tooltip {
    top: 30px;
    right: -2px;
    width: min(278px, calc(100vw - 44px));
    max-height: 46vh;
    overflow: auto;
    font-size: 12px;
  }

  label {
    font-size: 11px;
  }

  select,
  .date-input {
    height: 36px;
    font-size: 16px;
  }

  .segmented-control {
    height: 38px;
  }

  .segmented-control span {
    height: 32px;
    font-size: 12px;
  }

  #status,
  .legend,
  .nodata-legend {
    font-size: 11px;
  }

  .ownership-banner {
    padding: 6px 7px;
    font-size: 10px;
  }

  .timeseries-panel {
    right: 10px;
    bottom: 10px;
    left: 10px;
    transform: none;
    width: auto;
    max-height: 44vh;
    padding: 10px;
  }

  .timeseries-chart {
    width: 920px;
    height: 300px;
  }

  .timeseries-status,
  .timeseries-hover,
  .timeseries-summary {
    font-size: 12px;
  }

  .leaflet-top.leaflet-right {
    top: auto;
    bottom: 10px;
  }

  .leaflet-top.leaflet-right .leaflet-control {
    margin-top: 0;
    margin-bottom: 10px;
  }
}

@media (max-width: 340px) {
  .panel {
    max-height: 58vh;
  }

  .date-range {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .segmented-control {
    grid-template-columns: 1fr;
    height: auto;
  }

  .segmented-control span {
    height: 30px;
  }
}
