* {
  box-sizing: border-box;
}

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

#map {
  width: 100%;
  height: 100%;
  min-height: 100vh;
}

.panel {
  position: fixed;
  z-index: 25;
  max-height: calc(100vh - 24px);
  display: flex;
  flex-direction: column;
  padding: 12px 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.12);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.4;
}

.panel-right {
  top: 12px;
  right: 12px;
  left: auto;
  max-width: min(20rem, calc(100vw - 24px));
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-shrink: 0;
}

.panel-title {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: #1a1a1a;
}

.panel-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  color: #333;
  cursor: pointer;
  white-space: nowrap;
}

.panel-toggle-btn:hover {
  background: #f5f5f5;
}

.panel-toggle-chevron {
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #555;
  transition: transform 0.2s ease;
}

.panel-collapsed .panel-toggle-chevron {
  transform: rotate(-90deg);
}

.panel-body {
  overflow: auto;
  min-height: 0;
  flex: 1;
}

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

.panel-collapsed {
  max-height: none;
  overflow: visible;
}

.panel-fieldset {
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
}

.panel-fieldset legend {
  padding: 0 4px;
  font-size: 12px;
  font-weight: 600;
  color: #444;
}

.country-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.country-bulk-btn {
  flex: 1;
  padding: 5px 8px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
}

.country-bulk-btn:hover {
  background: #f5f5f5;
}

.country-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 10px;
  align-items: start;
}

.chk,
.radio {
  display: block;
  margin: 4px 0;
  cursor: pointer;
}

.country-grid .chk {
  margin: 2px 0;
}

.panel-sub {
  margin-bottom: 12px;
}

.panel-sub.hidden {
  display: none;
}

.island-select {
  width: 100%;
  margin-top: 4px;
  font-size: 12px;
}

.slider-label {
  display: block;
  margin-top: 8px;
  font-size: 12px;
  color: #444;
}

#bathy-opacity {
  width: 100%;
  margin: 4px 0 8px;
}

#bathy-style {
  width: 100%;
  margin-top: 4px;
  padding: 4px;
  font-size: 12px;
}

.hint {
  margin: 6px 0 0;
  font-size: 11px;
  color: #666;
}

.panel-foot {
  margin: 0;
  font-size: 11px;
  color: #666;
}

.measure-fieldset {
  margin-bottom: 12px;
}

.measure-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.measure-fieldset .measure-btn {
  flex: 1;
  min-width: 0;
  padding: 6px 10px;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 13px;
}

.measure-fieldset .measure-btn:hover {
  background: #f5f5f5;
}

.measure-fieldset .measure-btn.is-active {
  border-color: #1565c0;
  background: #e3f2fd;
  color: #0d47a1;
}

.measure-fieldset .measure-btn-secondary {
  font-size: 12px;
}

.measure-readout {
  margin: 8px 0 0;
  padding: 0;
  line-height: 1.45;
  color: #222;
  min-height: 2.6em;
  font-size: 12px;
}

@media (max-width: 640px) {
  .panel-right {
    max-width: calc(100vw - 24px);
    max-height: min(40vh, calc(100vh - 24px));
    font-size: 12px;
  }
}
