* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; font-family: "Segoe UI", Arial, sans-serif; }

#sidebar {
  position: absolute; left: 0; top: 0; bottom: 0; width: 360px;
  overflow-y: auto; background: #f4f6f8; border-right: 1px solid #d7dde3;
  padding: 14px 16px; box-sizing: border-box;
  display: flex; flex-direction: column;
}
#sidebar.name-search-active { overflow: hidden; }
#sidebar.station-detail-active { overflow: hidden; }
#map { position: absolute; left: 360px; right: 0; top: 0; bottom: 0; background: #aadaff; }
.map-attribution {
  position: fixed; right: 12px; bottom: 12px; z-index: 20;
  max-width: min(700px, calc(100vw - 384px));
  border: 1px solid rgba(0, 0, 0, .12); border-radius: 3px;
  background: rgba(255, 255, 255, .92); color: #39434b;
  font-size: 10px; line-height: 1.25;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.map-attribution-line {
  padding: 4px 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.map-sources-toggle {
  display: flex; width: 30px; min-width: 30px; height: 24px; margin: 0; padding: 3px;
  align-items: center; justify-content: center;
  color: #39434b; background: transparent; border: 0; border-radius: 3px;
  line-height: 1;
}
.map-sources-toggle:hover, .map-sources-toggle:focus-visible { background: rgba(224, 231, 236, .9); }
.map-sources-icon {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.map-sources-details {
  position: absolute; right: 0; bottom: calc(100% + 7px); width: 340px;
  padding: 10px 34px 9px 11px; color: #39434b; background: rgba(255, 255, 255, .97);
  border: 1px solid rgba(0, 0, 0, .15); border-radius: 6px;
  box-shadow: 0 4px 16px rgba(25, 35, 44, .2); font-size: 11px; line-height: 1.45;
}
.map-sources-details strong { display: block; margin-bottom: 5px; font-size: 11px; }
.map-sources-details > div + div { margin-top: 4px; }
.map-sources-close {
  position: absolute; top: 4px; right: 5px; width: 26px; height: 26px;
  margin: 0; padding: 0; color: #5a6670; background: transparent;
  border: 0; border-radius: 4px; font-size: 20px; line-height: 24px;
}
.map-sources-close:hover, .map-sources-close:focus-visible { color: #27323a; background: #e7ecf0; }
body.map-sources-collapsed .ol-scale-line { right: 50px; bottom: 12px; }
body:not(.map-sources-collapsed) .ol-scale-line { right: 12px; bottom: 39px; }
.map-attribution[hidden], .map-sources-details[hidden], .map-sources-toggle[hidden] { display: none; }
}

h1 { font-size: 18px; margin: 0 0 4px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .03em;
     color: #4a5560; margin: 18px 0 8px; }
.muted { color: #6b7680; font-size: 12px; }

section { border-top: 1px solid #e2e7ec; padding-top: 2px; }

input[type=text], input[type=number] {
  width: 100%; padding: 7px 9px; border: 1px solid #c2cad2; border-radius: 6px;
  font-size: 14px;
}
.coord-row { display: flex; gap: 8px; }
.coord-row label { flex: 1; font-size: 12px; color: #4a5560; }
.altitude-field { display: block; margin-top: 8px; color: #4a5560; font-size: 12px; }
.altitude-field input { margin-top: 3px; }
.coord-field-hint { display: block; margin-top: 4px; color: #6b7680; font-size: 11px; line-height: 1.2; white-space: nowrap; }
button {
  margin-top: 8px; width: 100%; padding: 8px; border: 0; border-radius: 6px;
  background: #2f6fb0; color: #fff; font-size: 14px; cursor: pointer;
}
button:hover { background: #285f96; }

#results, #nearest { margin-top: 8px; }
.algorithm-summary {
  margin: 10px 0 7px; padding: 9px 10px; color: #33434f; background: #eaf1f7;
  border: 1px solid #c8d8e5; border-radius: 7px; font-size: 12px; line-height: 1.45;
}
.algorithm-summary strong { color: #203847; }
.algorithm-summary .formula-row + .formula-row { margin-top: 3px; }
.algorithm-unavailable {
  margin-top: 9px; padding: 8px 9px; color: #725423; background: #fff8e8;
  border: 1px solid #e6d09b; border-radius: 7px; font-size: 11px; line-height: 1.4;
}
.base-station-badge {
  display: inline-block; margin-left: 6px; padding: 1px 5px; color: #315a39;
  background: #e3f0e1; border-radius: 8px; font-size: 9px; vertical-align: 1px;
}
.climate-download-status { margin-top: 6px; font-size: 11px; line-height: 1.35; }
.coordinate-error {
  color: #8f2d25;
  background: #fff2ef;
  border: 1px solid #e4b5ae;
  border-radius: 7px;
  padding: 9px 10px;
  font-size: 12px;
  line-height: 1.4;
}
#sidebar.name-search-active #nameSearchSection {
  flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden;
}
#sidebar.name-search-active #nameSearchSection h2,
#sidebar.name-search-active #nameSearchSection input { flex: 0 0 auto; }
#sidebar.name-search-active #results {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-gutter: stable; padding-right: 5px;
  scrollbar-width: thin; scrollbar-color: #aab5bf #f4f6f8;
}
#sidebar.name-search-active #results::-webkit-scrollbar { width: 11px; }
#sidebar.name-search-active #results::-webkit-scrollbar-track {
  background: #f4f6f8; border-radius: 8px;
}
#sidebar.name-search-active #results::-webkit-scrollbar-thumb {
  min-height: 42px; background: #aab5bf; background-clip: padding-box;
  border: 2px solid #f4f6f8; border-radius: 8px;
}
#sidebar.name-search-active #results::-webkit-scrollbar-thumb:hover { background: #8795a1; }
#sidebar.name-search-active #results::-webkit-scrollbar-corner { background: #f4f6f8; }
#sidebar.name-search-active #coordSearchSection,
#sidebar.name-search-active #detailSection,
#sidebar.name-search-active .legend { display: none; }
#detailSection[hidden] { display: none !important; }
#sidebar.station-detail-active #detailSection {
  display: flex; flex: 1 1 280px; min-height: 210px; flex-direction: column; overflow: hidden;
}
#sidebar.station-detail-active #detailSection > h2 { flex: 0 0 auto; }
#sidebar.station-detail-active #detail {
  display: flex; flex: 1 1 auto; min-height: 0; flex-direction: column;
}
.item {
  padding: 7px 9px; border: 1px solid #e2e7ec; border-radius: 6px;
  background: #fff; margin-bottom: 6px; cursor: pointer; font-size: 13px;
}
.item:hover { border-color: #2f6fb0; }
.item .name { font-weight: 600; }
.item .sub { color: #6b7680; font-size: 12px; }
.item.noc { opacity: .7; }
.results-summary { color: #4a5560; font-size: 12px; margin: 4px 0 8px; }
.results-group { color: #6b7680; font-size: 11px; font-weight: 700; letter-spacing: .04em;
                 margin: 10px 2px 5px; text-transform: uppercase; }
.search-status { padding: 8px 2px; }
.kind-badge { display: inline-block; margin-left: 6px; padding: 1px 5px; border-radius: 8px;
              font-size: 9px; font-weight: 600; vertical-align: 1px; }
.station-kind { background: #e4eef8; color: #2f6fb0; }
.settlement-kind { background: #e9f1df; color: #526c35; }
.coordinate-note { margin-top: 9px; padding: 7px 8px; border-radius: 5px; background: #e9edf1;
                   color: #65717b; font-size: 11px; line-height: 1.35; }

#detail .row { font-size: 13px; margin: 3px 0; }
#detail .label { color: #6b7680; display: inline-block; min-width: 110px; }
.files {
  flex: 1 1 150px; min-height: 96px; max-height: min(34vh, 300px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable;
  padding: 3px 5px 3px 0; scrollbar-width: thin; scrollbar-color: #aab5bf #f4f6f8;
}
.files::-webkit-scrollbar { width: 10px; }
.files::-webkit-scrollbar-track { background: #f4f6f8; border-radius: 8px; }
.files::-webkit-scrollbar-thumb {
  min-height: 38px; background: #aab5bf; background-clip: padding-box;
  border: 2px solid #f4f6f8; border-radius: 8px;
}
.file-row { display: flex; align-items: stretch; gap: 5px; margin: 4px 0; }
.file-preview-button {
  display: flex; flex: 1 1 auto; min-width: 0; align-items: center; justify-content: space-between;
  gap: 8px; width: auto; margin: 0; padding: 7px 8px; text-align: left;
  background: #fff; color: #1f5a8f; border: 1px solid #d7dde3; border-radius: 5px;
  font-size: 12.5px; line-height: 1.25; word-break: break-word;
}
.file-preview-button:hover { background: #eef4fa; border-color: #9eb9d0; }
.file-size { flex: 0 0 auto; color: #7a858e; font-size: 11px; font-weight: 400; }
.file-download-button {
  display: flex; flex: 0 0 34px; align-items: center; justify-content: center;
  color: #1f5a8f; background: #fff; border: 1px solid #d7dde3; border-radius: 5px;
  font-size: 18px; font-weight: 700; line-height: 1; text-decoration: none;
}
.file-download-button:hover { background: #e5eff8; border-color: #9eb9d0; }
.badge { display: inline-block; font-size: 11px; padding: 1px 6px; border-radius: 10px;
         background: #e3edf6; color: #2f6fb0; margin-left: 6px; }

.file-preview {
  position: fixed; z-index: 1000; left: 380px; right: 20px; top: 20px; bottom: 20px;
  display: flex; flex-direction: column; min-width: 320px; min-height: 240px;
  background: #fff; border: 1px solid #bfc8d0; border-radius: 9px;
  box-shadow: 0 12px 38px rgba(30, 42, 52, .28); overflow: hidden;
}
.file-preview[hidden] { display: none; }
.file-preview-header {
  display: flex; flex: 0 0 auto; align-items: center; justify-content: space-between;
  gap: 14px; min-height: 58px; padding: 9px 11px 9px 14px;
  background: #f4f6f8; border-bottom: 1px solid #d7dde3;
}
.file-preview-heading { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-preview-label { color: #6b7680; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
#filePreviewTitle { overflow: hidden; color: #27323a; font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 7px; }
.file-preview-download {
  padding: 7px 11px; color: #fff; background: #2f6fb0; border-radius: 5px;
  font-size: 12px; font-weight: 600; text-decoration: none;
}
.file-preview-download:hover { background: #285f96; }
.file-preview-close {
  width: 34px; height: 34px; margin: 0; padding: 0; color: #4d5962; background: transparent;
  border: 1px solid #cbd2d8; border-radius: 5px; font-size: 24px; line-height: 28px;
}
.file-preview-close:hover { color: #1f2930; background: #e5e9ed; }
#filePreviewFrame { flex: 1 1 auto; width: 100%; min-height: 0; border: 0; background: #fff; }
.file-preview-message { margin: auto; max-width: 420px; padding: 24px; color: #5c6871; text-align: center; }

.ol-scale-line {
  left: auto; right: 12px; bottom: 39px; padding: 3px 5px;
  background: rgba(40, 48, 56, .78); border-radius: 5px;
  transition: right .18s ease, bottom .18s ease;
}
.ol-scale-line-inner { min-width: 110px; color: #fff; border-color: #fff; font-size: 11px; }

@media (max-height: 650px) {
  #sidebar.station-detail-active #coordSearchSection,
  #sidebar.station-detail-active .legend { display: none; }
  #sidebar.station-detail-active #detailSection { min-height: 190px; }
  .files { min-height: 80px; max-height: none; }
}

@media (max-width: 760px) {
  .map-attribution { max-width: calc(100vw - 24px); }
  .map-sources-details { width: min(340px, calc(100vw - 24px)); }
  .file-preview { left: 12px; right: 12px; top: 12px; bottom: 12px; min-width: 0; min-height: 220px; }
  .file-preview-header { min-height: 52px; }
  .file-preview-download { padding: 6px 8px; }
}

.legend { margin-top: 20px; font-size: 12px; color: #4a5560; }
.legend span { display: flex; align-items: center; gap: 6px; margin: 4px 0; }
.dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; border: 1px solid #fff; }
.dot.has { background: #2e8b57; }
.dot.placed { background: #3a78c2; }
.dot.noc { background: #b0b7be; }
.st-icon { background: none; border: none; }
.st-dot {
  display: block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #fff; box-sizing: border-box; box-shadow: 0 0 1.5px rgba(0,0,0,.35);
}
.st-dot.has { background: #2e8b57; }
.st-dot.placed { background: #3a78c2; }

.ol-tip {
  background: rgba(40, 48, 56, .92); color: #fff; font-size: 12px;
  padding: 3px 7px; border-radius: 4px; white-space: nowrap;
  pointer-events: none; box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
}
