:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --line: #d6dde5;
  --text: #17202a;
  --muted: #64748b;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --forecast: #c2410c;
  --track: #2563eb;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--line);
  background: var(--panel);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--line);
}

.topbar h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.summary {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  color: var(--muted);
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.search {
  display: grid;
  gap: 6px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.search input {
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  text-transform: none;
}

.payload-list {
  overflow: auto;
  min-height: 0;
}

.payload-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 12px;
  padding: 12px 18px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.payload-row:hover,
.payload-row.active {
  background: #edf8f6;
}

.payload-row strong {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.payload-row span {
  color: var(--muted);
  font-size: 12px;
}

.payload-row .altitude {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.payload-row span {
  font-variant-numeric: tabular-nums;
}

.map-pane {
  position: relative;
  min-width: 0;
  height: 100vh;
  min-height: 0;
}

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

.detail-panel {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 18px;
  z-index: 500;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid rgba(15, 23, 42, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
}

.detail-panel h2 {
  margin: 0;
  font-size: 18px;
  letter-spacing: 0;
}

.detail-panel p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.detail-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(72px, auto));
  gap: 8px;
}

.stat {
  display: grid;
  gap: 2px;
}

.stat span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.stat strong {
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.leaflet-popup-content {
  margin: 10px 12px;
  min-width: 160px;
}

.popup-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.landing-icon {
  display: grid;
  place-items: center;
  border: 2px solid #7f1d1d;
  border-radius: 50%;
  background: #fef2f2;
  box-shadow: 0 4px 14px rgba(127, 29, 29, 0.3);
  color: #991b1b;
  font-size: 22px;
  font-weight: 700;
  line-height: 1;
}

.station-icon {
  display: grid;
  place-items: center;
  border: 1px solid #334155;
  border-radius: 4px;
  background: #f8fafc;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.22);
  color: #334155;
  font-size: 16px;
  line-height: 1;
}

.landing-position {
  margin: 6px 0 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
}

.copy-position-button {
  width: 100%;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.copy-position-button:hover {
  border-color: var(--forecast);
  color: var(--forecast);
}

.copy-feedback {
  min-height: 16px;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 42vh 58vh;
  }

  .sidebar {
    order: 2;
    border-right: 0;
    border-top: 1px solid var(--line);
  }

  .map-pane {
    order: 1;
  }

  .detail-panel {
    left: 10px;
    right: 10px;
    bottom: 10px;
    grid-template-columns: 1fr;
  }

  .detail-stats {
    grid-template-columns: repeat(2, minmax(72px, 1fr));
  }
}
