* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  color: #e6edf3;
  background: #0d1117;
}

body {
  display: flex;
  min-height: 100vh;
}

#sidebar {
  width: 320px;
  flex: 0 0 320px;
  padding: 16px 18px;
  overflow-y: auto;
  background: #161b22;
  border-right: 1px solid #30363d;
}

#sidebar header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

#sidebar h1 {
  font-size: 18px;
  margin: 0;
  letter-spacing: 0.02em;
}

#sidebar h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7d8590;
  margin: 18px 0 8px;
  border-bottom: 1px solid #30363d;
  padding-bottom: 4px;
}

#sidebar label {
  display: block;
  font-size: 12px;
  color: #c9d1d9;
  margin-top: 10px;
}

#sidebar label.inline {
  display: inline;
  margin-left: 8px;
}

#sidebar input[type="number"],
#sidebar input[type="password"],
#sidebar input[type="text"],
#sidebar select {
  width: 100%;
  margin-top: 4px;
  padding: 6px 8px;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #e6edf3;
  border-radius: 6px;
  font: inherit;
}

#sidebar input[type="range"] {
  width: 100%;
  margin-top: 6px;
}

#sidebar .row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

#sidebar .row input[type="number"] {
  width: 60px;
}

button {
  margin-top: 10px;
  padding: 8px 12px;
  background: #238636;
  color: white;
  border: 1px solid #2ea043;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

button:hover { background: #2ea043; }

#logout {
  background: transparent;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 4px 10px;
  font-size: 12px;
  margin-top: 0;
}

.muted { color: #7d8590; font-size: 12px; }

#map {
  flex: 1;
  height: 100vh;
}

/* Login page */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #161b22;
  padding: 32px 28px;
  border: 1px solid #30363d;
  border-radius: 10px;
  width: 320px;
  text-align: center;
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}

.login-card input {
  padding: 10px;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #e6edf3;
  border-radius: 6px;
  font-size: 18px;
  text-align: center;
  letter-spacing: 0.3em;
}

.err { color: #f85149; font-size: 13px; min-height: 16px; margin: 0; }

#sidebar label.checkbox {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  color: #c9d1d9;
}

#sidebar label.checkbox input { width: auto; margin: 0; }

/* Plane markers */
.plane-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  text-shadow: 0 0 3px #000;
  font-size: 22px;
  line-height: 1;
}
.plane-icon svg { width: 22px; height: 22px; }

/* Airport markers */
.airport-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}
.airport-icon svg { display: block; }

/* Legend */
.legend {
  background: rgba(13, 17, 23, 0.9);
  color: #e6edf3;
  border: 1px solid #30363d;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  line-height: 1.35;
  max-width: 200px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}
.legend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.legend-header strong { font-size: 12px; letter-spacing: 0.03em; }
.legend-toggle {
  background: transparent;
  border: none;
  color: #7d8590;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
  margin: 0;
  line-height: 1;
}
.legend-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7d8590;
  margin: 8px 0 3px;
  border-bottom: 1px solid #30363d;
  padding-bottom: 2px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 1px 0;
}
.legend-plane svg,
.legend-airport svg { display: block; }
.legend-line {
  display: inline-block;
  width: 20px;
  height: 3px;
  background: #ffd33d;
  border: 1px solid #000;
  border-radius: 2px;
}
.legend.collapsed .legend-body { display: none; }
.legend.collapsed { max-width: 120px; }

.popup-table { font-size: 12px; }
.popup-table td { padding: 1px 6px 1px 0; }
.popup-table td:first-child { color: #7d8590; }

@media (max-width: 720px) {
  body { flex-direction: column; }
  #sidebar {
    width: 100%;
    flex: 0 0 auto;
    max-height: 50vh;
    border-right: none;
    border-bottom: 1px solid #30363d;
  }
  #map { height: 50vh; }
}
